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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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?
Code: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 warreng86, 11-10-2020, 02:04 PM
|
7 responses
1,360 views
0 likes
|
Last Post Today, 09:41 PM | ||
Started by Perr0Grande, Today, 08:16 PM
|
0 responses
5 views
0 likes
|
Last Post
by Perr0Grande
Today, 08:16 PM
|
||
Started by elderan, Today, 08:03 PM
|
0 responses
9 views
0 likes
|
Last Post
by elderan
Today, 08:03 PM
|
||
Started by algospoke, Today, 06:40 PM
|
0 responses
10 views
0 likes
|
Last Post
by algospoke
Today, 06:40 PM
|
||
Started by maybeimnotrader, Today, 05:46 PM
|
0 responses
14 views
0 likes
|
Last Post Today, 05:46 PM |
Comment