Forums › ProRealTime English forum › ProOrder support › Adjustment in code because combined stops can not be used with pro order › Reply To: Adjustment in code because combined stops can not be used with pro order
Hi
This part of the code is not to add 60 points to my entry but 60 points to my sl. I want it to buy as close as possible to the high of the previous 6 bars (5 min) and sell as close to the low of the last 6 bars. I want the sl to be 60 points below the high for a buy trade and 60 points above the low of the last 6 bars.
1 2 3 4 5 6 7 8 |
if not onmarket and time >= starttime and flag = 0 then buy Nlots contract at MaxPrice STOP set stop loss close- Minprice - 60 * pointsize endif if not onmarket and time >= starttime and flag = 0 then sellshort Nlots contract at MinPrice STOP set stop loss MaxPrice - close + 60 * pointsize |
The problem i have is that its not placing trades in real time.. in backtest the code works but in real time it doesnt place any trades.. how can i change the code so that it does place a trade even if price is volatile and already moved and orders are too close to price?
Another thing is it also doesnt keep orders open till its filled,, if not filled in first 5 min it cancels all pending orders.
Please run a backtest and see some days it doesnt place any trades. This is the code i have now.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
//------------------------------------------------------------------------- // Main code : UltimateSAF //------------------------------------------------------------------------- //------------------------------------------------------------------------- // Main code : MySystem(8) //------------------------------------------------------------------------- DEFPARAM CumulateOrders = false DEFPARAM FLATBefore = 084500 //09:00 DEFPARAM FLATAfter = 210000 //21:00 DEFPARAM PreLoadBars = 2000 ONCE nLots = 5 ONCE MaxPrice = 999999 ONCE MinPrice = 0 starttime = 090000 SET TARGET PROFIT 120 IF time = starttime THEN MaxPrice = max(close, highest[6](high)) //Il massimo/minimo delle ultime 12 barre MinPrice = min(close, lowest[6](low)) // (ogni ora = 12 barre da 5 minuti) flag=0 ENDIF if onmarket then flag = 1 endif //************************************************************************ // LONG if not onmarket and time >= starttime and flag = 0 then buy Nlots contract at MaxPrice STOP set stop loss close- Minprice - 60 * pointsize endif if not onmarket and time >= starttime and flag = 0 then sellshort Nlots contract at MinPrice STOP set stop loss MaxPrice - close + 60 * pointsize MaxPrice = 999999 MinPrice = 0 endif |
If you can please adjust code.
Thank you