Here is my strategy code:
protected override void OnBarUpdate() { if (CurrentBar < BarsRequiredToTrade) { return; } SetTrailStop(CalculationMode.Ticks, 80); if (Close[0] > Close[1] && (SystemPerformance.AllTrades.Count == 0 || BarsSinceExitExecution() > 10)) { EnterLong(); } } protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "StopLoss/ProfitTarget Test"; } else if (State == State.DataLoaded) { SetTrailStop(CalculationMode.Ticks, 80); } }
I'm familiar with historical fill processing (https://ninjatrader.com/support/help...ical_fill_.htm). I'm using standard order fill resolution.
But it doesn't seem to explain this for me.
I have slippage set to zero.
As I understand this we entered the long position at the open ($2666.50). Then we simulate the intrabar movement by assuming the price moves first to the closest of low or high which is, in this case, the low. The low is $2657.75. Since my stoploss is set at 80 tick (or $20), that's not a big enough drop to trigger the stoploss. Then we assume the price moves to the opposite extreme, in this case to the high, which is $2695.75. And then we assume it moves back down to the close which is not more than $20. So I would not have expected historical fill processing to have exited on this bar.
If we made some other assumptions about how price moved in the bar, like suppose it goes from the open to the high first. Well, in that case, I would have expected it to exit at $20 below the high, or $2675.75.
But instead, the exit price is all the way back down to the opening price...
Can you help me make sense of this?
By the way, most of the trades look exactly like I would expect. Even many that enter and exit in the same bar at different prices. But there are several that appear like the above example.
Thanks,
Comment