EnterShortLimit(GetCurrentAsk(), "SHORT");
I then have this code to set the exit point:
protected override void OnPositionUpdate(Position position, double averagePrice, int quantity, MarketPosition marketPosition) {
//Log("=== TYPE ===:" + position.MarketPosition, NinjaTrader.Cbi.LogLevel.Warning);
if (marketPosition == MarketPosition.Short) {
Log("ExitShortLimit:" + EMA(barsEMA)[0], NinjaTrader.Cbi.LogLevel.Warning);
ExitShortLimit(EMA(barsEMA)[0], "SHORT");
} else if (marketPosition == MarketPosition.Long) {
Log("ExitLongLimit:" + EMA(barsEMA)[0], NinjaTrader.Cbi.LogLevel.Warning);
ExitLongLimit(EMA(barsEMA)[0], "LONG");
}
}
In the backtest I see the orders correctly, but it did not trigger. I eventually closed the position with "Exit on Session Close" a few days later. See pic attached.
Why did the ExitShortLimit(EMA(barsEMA)[0], "SHORT"); not happen?
Thanks.
Comment