I have BUY entry condition and would like to set an initial stop at Close[1] - ATR(14)[1]*5.
I use SetStopLoss() on the OnBarUpdate method like so:
protected override void OnBarUpdate() { if (condition) [0] == bullish) { if (condition) [1] == sideways) { SetStopLoss("Enter Long",CalculationMode.Price, Close[1] - ATR(200)[1]*3, false); } EnterLong(1,"Enter Long"); }
Is there anything wrong here ? The help pages imply that for a static stop, "it is suggested to call this method from within the strategy OnStateChange()"
The problem is have it: once I hit my Stop Loss (at 110), and I enter a new long position, the stop loss is being sent at the same 110 price (instead of the updated to: Close[1] - ATR(200)[1]*3).
It's like the stop value is being cached and recycled. This looks like expected behaviour :
"You should always reset the stop loss price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position"
But how do I reset it ?
I've tried the following in both State.Configure method and OnBarUpdate with no success
if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss(CalculationMode.Price, ATR(14)[1]); }
Comment