Hi
What is the right code for a stop loss that is set after the opening bar.
long entry condition is met and position is opened. If after that first bar ( whichever time frame is set) the first candle is green then the SL is set at the opening price. If the first candle is red the SL is set at the close price minus x pips.
The reverse SL conditions for a short position.
Any ideas on the code would be greatly received.
Eccolo (SL=Stop Loss):
Bullish = close > open
Bearish = close < open
IF LongOnMarket AND Not LongOnMarket[1] THEN //prima barra dopo entrata a mercato
IF Bullish THEN
SL = TradePrice
ELSIF Bearish THEN
SL = close - 20*PipSize
ENDIF
ELSIF ShortOnMarket AND Not ShortOnMarket[1] THEN //prima barra dopo entrata a mercato
IF Bearish THEN
SL = TradePrice
ELSIF Bullish THEN
SL = close + 20*PipSize
ENDIF
ENDIF