Forums › ProRealTime English forum › ProOrder support › Move stop loss level to opening level › Reply To: Move stop loss level to opening level
08/15/2018 at 11:47 AM
#78269
There you go (not tested, though, let me know of any issue):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
IF Not OnMarket THEN StopLoss = 0 ENDIF DISTANCELONG=(abs(close - low) / pipsize) +5 IF STRATEGYLONG AND Not OnMarket THEN BUY 1 CONTRACT AT MARKET SET STOP PLOSS (abs(close - low) / pipsize) + 5 //DISTANCELONG SET TARGET PPROFIT PositionPrice + DISTANCELONG ENDIF IF LongOnMarket AND (close - TradePrice) >= (70 * pipsize) THEN StopLoss = TradePrice ENDIF IF LongOnMarket AND StopLoss THEN SELL AT StopLoss STOP ENDIF |
Beware that line 8 will only be executed next bar, since ProOrder takes a bar to know it’s On Market. Also, PPROFIT doesn’t want a price, but the number of PIPS!