Historical Fill Processing
NinjaTrader provides two system fill algorithms that can be used in a backtest. In addition, if you have some experience programming, you can script your own algorithm.
The two system fill algorithms are:
An algorithm that takes a conservative and more realistic approach to filling limit and stop limit orders.
|•||Limit orders only fill if the limit price was penetrated |
|•||Limit orders are always filled at the limit price specified never better (for example, if a limit order is submitted on bar n, NinjaTrader will check if the order is filled on bar n+1, if this bar gaps down and the limit order was a buy, the order would be filled at the limit price and NOT the high of bar n+1) |
An algorithm that takes a liberal approach to filling limit and stop limit orders.
|•||Limit orders fill if the limit price was touched |
|•||On gap down bars, buy limit orders will fill at the high of the gap down bar |
|•||On gap up bars, sell limit orders will fill at the low of the gap up bar |
Slippage can also be set to mimic market conditions. The value is expressed in "ticks", the minimum value of fluctuation for an instrument, and is only applied to market and stop market orders since slippage is not possible when using a limit order.
Special Circumstance with Forex backtests
During a backtest order quantity is an absolute value, which is in most cases different than in a real-time brokerage account. As an example, 1 traded FX lot at a live brokerage account might be the equivalent to 100,000 of notional value (check with your broker) however, in backtest a value of 1 is a literal value of 1 and not 100,000. Thus if you want to trade 100,000 in a backtest, you need to put in a value of 100,000. Just remember that if you convert your strategy from backtest to live you will need to amend the order quantities appropriately. (Please see the Running FX Strategies section for more information).