Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Vastly different results between running strategies live and backtest
Collapse
X
-
Vastly different results between running strategies live and backtest
I get very different results running strategies live compared to backtesting over the same period. I am not just talking about slippage. When run live, the strategy will take a different number of trades at different times.Tags: None
-
Hello samish18,
Thank you for your post.
Please review the help guide page on the differences on real-time vs backtest.
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. Instead these are filled based on logical rules from processing historical data.- When in historical data, only the Open, High, Low, and Close will be available 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' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.
- This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with. The orders placed will need to use the BarsInProgress (BarsArray) index of that finer resolution series.
In NinjaTrader 8, there have been two new enhancements so that programmers may not have to manually add this secondary series and code the script for high accuracy fills (Order Fill Resolution) or for intra-bar actions (TickReplay) depending on the needs of the script.
Note: bar types that are IsRemoveLastBarSupported cannot be used with TickReplay and generally cause inaccurate results when backtesting in historical data.
Note: High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.
Please see this forum post for a detailed explanation:
https://forum.ninjatrader.com/forum/...-backtest-live
Please let us know if we may be of further assistance.Gaby V.NinjaTrader Customer Service
- When in historical data, only the Open, High, Low, and Close will be available and there will be no intra-bar data.
-
I am using onbarClose and am expecting it to execute at the end of the bar - that is not my issue. My issue is that when I run a strategy live, I may execute 5 trades, but backtesting over the same period in may execute 2 trades with only 1 of those matching up with a live trade
Comment
-
Hello samish18,
Are you using High Order Fill Resolution or added a 1-tick data series? The added 1-tick series for intra-bar granularity is still necessary no matter what Calculate setting is used for accurate fill times and prices.
High Order Fill Resolution would implement 1-tick intra-bar granularity as long as Tick Replay is not enabled.Gaby V.NinjaTrader Customer Service
Comment
-
Thanks for clarifying, it is appreciated.
To understand why the script is having differences, I recommend using prints to print all of the data being processed by the strategy.
In the print, print the time of the bar, print the open, high, low, and close of the bar, then all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.
Enable TraceOrders to see if orders are being submitted, ignored, rejected, or cancelled.
It would be helpful if you could run the script in real-time and then also in backtest so we can compare the two outputs. Playback using Market Replay would also be very similar to real-time.
Prints will output to the New -> NinjaScript Output window.
Below I am providing a link to a forum post that demonstrates using prints to understand behavior. Please take a look at the videos that demonstrate adding prints to a script to get further information about the behavior of the script.
If you need assistance creating a print or enabling TraceOrders, please let me know.
I look forward to receiving both of the output files.Gaby V.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,404 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
95 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
8 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
159 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
8 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment