We have developed a custom strategy using our own logic in NinjaTrader. We are working in the backtest mode in the provided examples below.
In the scope of one OnBarUpdate event, we can submit up to 10 orders with the same stop price. As a result, the strategy returns order objects, but sometimes the fill or exit price are 1 tick away from the expected.
The majority of the scenarios happen when we exit the orders and fill the reversal orders at the same time: the entry price of the reversal orders can be 1 tick away from the exit price. The expectation is that the entry price and exit price should be the same.
When testing the strategy, we noticed that some of the orders are processed differently from what we expect.
Here are some examples:
- At 09:01:20 AM, we are closing 5 long orders at 84.02, and fill 5 short orders at the price of 84.03.
- In log1.txt log1.txt , at 08.10.2023 09:01:20.417 AM the signal to go Long was received (to open a reversal)
- At 08.10.2023 09:01:20.417 AM the algorithm attended to open long orders at 83.99 and failed.
- Short positions were filled at 84.02 by 08.10.2023 09:01:20.507 AM with the stop price 83.99.
- Long positions were submitted with the stop price of 83.99
- Long positions were filled at the price of 84.03 by 08.10.2023 09:01:20.532 AM
- The historical data shows the following information for every tick:
How NinjaTrader decides when and at what price the orders are going to get closed?
Does NinjaTrader group the orders to open them at the same price? If yes, could you please describe the grouping process or define general rules?
Why in the case above NinjaTrader didn’t fill one position at 84.02 and the rest of orders at 84.03?
Why in the case above the positions weren’t closed at 84.01?
- At 09:52:50, we are closing 5 short positions at 83.79 and open 5 long positions at 83.78
- In log2.txt log2.txt , at 08.10.2023 09:52:50.633 AM the signal to open reversal orders was received.
- At 08.10.2023 09:52:50.633 AM, the strategy failed to create 5 Long orders with stop price 83.77
- Short positions were closed by 08.10.2023 09:52:51.867 AM with the price of 83.79 (the stop price of all orders was 83.77)
- The strategy submitted 5 long orders with stop price of 83.77 at 08.10.2023 09:52:51.867 AM.
- The long positions were filled by 08.10.2023 09:52:51.936 AM with the fill price 83.78
Could you please help us and answer the following questions:
Why in the case above NinjaTrader fill all long positions at 83.78?
Why in the case above the positions weren’t closed at 83.78?
Here are the parameters for Historicall fill processing:
Please let us know if you have any questions or if any additional details are required.

Comment