I am getting different results using live simulated and strategy analyzer (see attached). I am using "Tick Replay" to run the strategy analyzer as close as possible to running it live. The backtest gives me different success rate than running it live. Trying to understand what I am doing wrong.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Different results from backtest and strategy analyzer
Collapse
X
-
Different results from backtest and strategy analyzer
Hello,
I am getting different results using live simulated and strategy analyzer (see attached). I am using "Tick Replay" to run the strategy analyzer as close as possible to running it live. The backtest gives me different success rate than running it live. Trying to understand what I am doing wrong.Tags: None
-
Hello pyraxic,
To get similar results 1 tick intra-bar granularity is necessary.
Below is a link to a forum post that discusses this.
And a link to an example script that writes to file the differences.
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.Chelsea B.NinjaTrader Customer Service
-
Thank you, Chelsea.
I went through the video you created as well as all the links in your post. Just to make sure that in order to match the Backtest results with the Real-time data is to add "AddDataSeries()" function to my code as stated in [1]? I do have TickReply enabled in Strategy Analyzer when running the Backtest. Is there anything else I need to do besides adding AddDataSeries() to my code?
Here is what I have so far. Would this give me the correct results?
[1] https://ninjatrader.com/support/foru...ularity?t=6652Code:else if (State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Tick, 1); MACD1 = MACD(Close, Convert.ToInt32(Fast), Convert.ToInt32(Slow), Convert.ToInt32(Smooth)); MACD1.Plots[0].Brush = Brushes.DarkCyan; MACD1.Plots[1].Brush = Brushes.Crimson; AddChartIndicator(MACD1); } } protected override void OnBarUpdate() { if (CurrentBar < BarsRequiredToTrade) return; if (BarsInProgress != 0) return; if (CurrentBars[0] < 1) return; if (BarsInProgress == 0) { if (IsFirstTickOfBar){ TradeTaken = false; } // Enter Long if ((CrossAbove(MACD1.Default, MACD1.Avg, 1)) && TradeTaken == false) { EnterLong(1, 1, @"Long"); TradeTaken = true; } // Enter Short if ((CrossBelow(MACD1.Default, MACD1.Avg, 1)) && TradeTaken == false) { EnterShort(1, 1, @"Short"); TradeTaken = true; } } }Last edited by pyraxic; 11-30-2020, 04:00 AM.
Comment
-
Hello pyraxic,
Other than adding the 1 tick series, it is necessary to submit the entry orders to that 1 tick series using the BarsInProgress index (likely 1), as you have done in the sample code you have provided.
EnterLong(1, 1, @"Long");
This is correct for placing the order to the added tick series.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello pyraxic,
Be sure to focus on prints and TraceOrders.
To confirm, an entry order is being submitted in the opposite direction to reverse the position and this is unexpected?
Print the time of the bar and all values used in the condition that places that order.
This will tell you why that condition is evaluating as true on that bar. From there you can decide if you want to change the condition.
Below is a link to a forum post that demonstrates using Print().
And a link to the help guide on TraceOrders.
Provide the output saved to a text file and we will be happy to assist with analyzing the output.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|
? Would that mean that the Backtest will enter trades every 100 ticks if the condition matches instead of 1000 ticks?
Comment