Buy at current bar and not at next bar open
Forums › ProRealTime English forum › ProOrder support › Buy at current bar and not at next bar open
- This topic has 6 replies, 4 voices, and was last updated 8 years ago by mvajdi.
-
-
04/19/2016 at 3:49 PM #566404/19/2016 at 3:57 PM #5668
Hello Eugene,
Unfortunately, it is not possible at the moment to do this. Each condition are tested once a bar. Sorry.
Do you have any other question about coding? Don’t hesitate to create new topics in forums for specific question about prorealtime coding 馃檪
04/19/2016 at 11:57 PM #5692Thanks Nicolas,
I am trying to trade 30min, using the bollinger band. Any spikes above the bollinger to take a reversal trade on the same bar, both on the long and short side. Can someone help me see what’s wrong with my code (below)? The backtest does not show the trades according to my thought process. Sometimes it opens where I see the price overshoots the bollinger, and sometimes it does not open a trade where I see the spike.
Ideally, this聽strategy聽uses the same (current) bar to get the signal and to open the trade but not聽the next open bar.
Appreciate any help here.
Tks.
—————————————————————————————————————————————————-
12345678910111213141516171819202122232425// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedBoll = 20// Conditions to enter long positionsindicator1 = highindicator2 = BollingerDown[Boll](close)c1 = (indicator1 < indicator2)IF c1 THENBUY 1 CONTRACT AT MARKETEndif// Conditions to enter short positionsindicator5 = closeindicator6 = BollingerUp[Boll](close)c3 = (indicator5 > indicator6)IF c3 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Stops and targetsSET TARGET $PROFIT 104/20/2016 at 9:39 AM #5700You are here testing a high spike below the bollinger bands for a long position. You should use “low” in your indicator1 variable in my opinion.
And use “high” instead of close in indicator5.
Also, actually you are testing a spike out of the bollinger bands and not a re-entry in them… it maybe filter some bad signals ..
Your target profit of 1$ is very minimalist and you don’t even exit position in loss, how do you manage that? because there will be some trades that will never be in gain 馃檪
04/21/2016 at 11:43 AM #5748Tks Nicolas,
Makes a lot of sense, I somehow didi;t see the obvious where there should be a low, for the buy signal and a high for the sell signal.
I am trying to trade/scalp the current bars, but unfortunately it is only for the next bar open. Is there a way to trigger the execution at the current bar?
Tks
04/21/2016 at 12:00 PM #5749Hi, i developed my聽code to buy and sell when the price touch MA, i did it with a LIMIT order when conditions are true, when signal is = 1, then the system sets up a limit order 聽ready to go :). Also works with an STOP order.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899REM ALEX v.0.2 @Binomio Trading Abril 2016REM Estrategia ProOrder ProRealTimeREM No acumular 贸rdenesDEFPARAM CumulateOrders=FalseREM Horario de operativaDEFPARAM FlatBefore = 153000DEFPARAM FlatAfter = 212900REM Variablesmm = average[8](close)uma = Highest[8](high)umb = Lowest[8](low)REM Establecemos nuevo m铆nimo en movimiento bajistaif umb<mm and high<mm thenumb=Lowest[8](low)endifif high>mm thenumb=mmendifREM Establecemos nuevo m谩ximo en movimiento alcistaif uma>mm and low>mm thenuma=Highest[8](high)endifif low<mm thenuma=mmendifREM Establecimiento del ultimo toque con la media m贸vilif barindex<2 thenltp = mmendifif(High[1]>mm[1] and Low[1]<mm[1]) thenltp = mm[1]endifREM Condici贸n de entrada Largoif (uma-ltp)>objetivo and uma>mm thencompra=1endifif (uma-ltp)<=objetivo thencompra=0endifREM Condici贸n de entrada cortoif (ltp-umb)>objetivo and umb<mm thenventa=1endifif (ltp-umb)<=objetivo thenventa=0endifREM GESTION MONETARIAREM C谩lculo de contratos a operarinitLOT = 1stepPROFIT = 400*PointValuemyLOT = max(initLOT,initLOT+ROUND((strategyprofit-stepPROFIT)/stepPROFIT))REM Anticipaci贸n a la media m贸vil en la entradaplusL = mm - mm[1]plusC = mm[1] - mmpreciocompra = mm+plusLprecioventa = mm-plusCREM Bloqueo de apertura de posiciones en la vela siguiente a cierreLastTrade = BarIndex - TradeIndexREM Establecer PROFIT Y STOPSREM PROFIT LARGOProfitL = ((uma-ltp)*0.4)REM PROFIT CORTOSProfitC = ((ltp-umb)*0.25)REM STOP LARGOSStopL = ((uma-ltp)*0.75)REM STOP CORTOSStopC = ((ltp-umb)*0.75)REM Entrada de posiciones largasIF NOT LongOnMarket AND NOT ShortOnMarket AND compra=1 and lasttrade>1 thenBUY myLOT SHARE AT preciocompra LIMITSET STOP ploss StopLSET TARGET pPROFIT ProfitLENDIFREM Entrada de posiciones cortasIF NOT ShortOnMarket AND NOT LongOnMarket AND venta=1 and lasttrade>1 THENSELLSHORT myLOT SHARE AT precioventa LIMITSET STOP pLOSS StopCSET TARGET pPROFIT ProfitCENDIFREM DISTANCIA OBJETIVO MOVIMIENTO DEL PRECIO:objetivo=45Hope it helps you!
Cheers!
06/03/2016 at 2:58 PM #8752 -
AuthorPosts
Find exclusive trading pro-tools on