Forums › ProRealTime English forum › ProOrder support › Stop / close Position on close bar or alert with trigger too close › Reply To: Stop / close Position on close bar or alert with trigger too close
11/21/2019 at 8:02 PM
#113358
Roberto’s code does not allow for gaps between the close and the open of the next candle which is the price you will actually be buying at. This code does:
1 2 3 4 5 6 7 8 9 10 11 12 |
MyStop = 20 * pipsize //20 pips SL IF Not OnMarket AND MyConditions THEN BUY 1 CONTRACT AT MARKET SET TARGET pPROFIT 50 ENDIF IF LongOnMarket THEN stoploss = tradeprice - mystop IF close <= StopLoss THEN SELL AT MARKET ENDIF ENDIF |
You have to be aware that by only closing a trade at the close of a candle (open of the next in reality) you are leaving yourself open to price blowing straight through your stop loss value and falling massively lower before you sell which could equal a very big loss compared to your stop loss value.