Why does the trading signal not pass at the close of the bar when testing ?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy Analyzer - why does the trading signal not pass at the close of the bar ?
Collapse
X
-
This is my strategy. The indicator when crossing the line "0" generates a buy signal, when crossing below "0" to sell. But as you can see on the chart, the deal closes only at the beginning of the next bar. How can I make the deal close in tests at the end of the bar on which the signal formed.
This is exactly what happens when testing on a demo account.
Comment
-
Hello jonrussia,
Thank you for your reply.
There are several methods your strategy can use to calculate when running on live data on a chart or on Market Replay data. You can choose to run the strategy On Bar Close, which is what appears is occurring here, On Price Change, or On Each Tick. On Bar Close means that your logic will be evaluated only once per bar, when it closes. Any orders generated by a signal will be entered on the bar following the signal bar in this case. On Price Change and On Each Tick allow for intrabar entry.
Also, you should expect that a strategy running real-time (live brokerage account, live market simulation, Market Replay etc...) will produce different results than the performance results generated during a backtest using historical data on a chart or in the Strategy Analyzer. This difference may be more easily seen on certain Bars types (e.g. Point and Figure) than others due to their inherent nature in bar formation.
During a backtest you can select conservative or liberal fill algorithms which will produce different results. Fills are determined based on 4 data points, OHLC of a bar since that is the only information that is known during a backtest and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.
Because of this, OnBarUpdate will only update 'On bar close' in the Strategy Analyzer or on Historical data as it does not have the intra-bar information necessary for 'On price change' or 'On each tick'.
Also, here is a link to the differences on real-time vs backtest (historical).
Adding intra-bar granularity can help with this.
Intra-bar granularity adds a second data series such as a 1 tick series so that the strategy has finer granularity in the historical data in between the OHLC of the primary series. This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with.
In NinjaTrader 8, there have been two new enhancements so that programmers do not have to manually add this secondary series and code the script to for high accuracy fills (Order Fill Resolution) and for intra-bar actions (TickReplay).
Here is a link to our forums that goes into depth on using Order Fill Resolution and Tick Replay to ensure your backtests are as close to real time results as possible:
Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.
High Fill Order Resolution and TickReplay cannot be used together. If it is necessary to have both, it is still possible to add intra-bar granularity to a script in the code itself for order fill accuracy and use TickReplay to update indicators with Calculate set to OnPriceChange or OnEachTick historically.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by cmtjoancolmenero, Yesterday, 03:58 PM
|
6 responses
28 views
0 likes
|
Last Post Today, 08:55 AM | ||
Started by gbourque, Today, 06:39 AM
|
2 responses
14 views
0 likes
|
Last Post
by gbourque
Today, 07:05 AM
|
||
Started by rexsole, Today, 08:39 AM
|
0 responses
4 views
0 likes
|
Last Post
by rexsole
Today, 08:39 AM
|
||
Started by trilliantrader, Yesterday, 03:01 PM
|
3 responses
31 views
0 likes
|
Last Post Today, 08:28 AM | ||
Started by Brevo, Today, 01:45 AM
|
1 response
14 views
0 likes
|
Last Post Today, 08:14 AM |
Comment