View Full Version : Backtesting Multi-Timeframe does not match real market data.
MONTERO
09-25-2007, 10:40 AM
I have a Multi-Timeframe strategy based on two volume charts and one tick chart. It calculates on bar close of the primary timeframe. If I back test on ES or ER and compare the results with the strategy applied to a chart of the same time period they never match. This is very distressing because I do not know which data to believe so I can optimize the strategy intervals.
NinjaTrader_Ray
09-25-2007, 10:44 AM
Can you clarify what you mean by comparing the strategy to a chart of the same time period?
- Do you mean comparing the Strategy Analyzer chart to a real-time chart of the same interval?
MONTERO
09-25-2007, 11:01 AM
I run a backtest and then select the "Periods" and pick a day from the backtest periods. I then compare the total of that day to the real chart (not backtest chart) by manually calculating all of the trades in the real chart.
Whitmark has been helping me and gave me the idea to verify the trades on the real chart with the trades listed under the "Trades" tab. Those do not match the trades in the real chart either.
NinjaTrader_Ray
09-25-2007, 01:30 PM
The trades in the trade tab does not necessarily reflect the backtest. The performance stats of in the "Performance" tab reflects the executions in the account. A backtest reflects executions within the strategy. The account could have executions generated outside of the strategy or, generated by multiple strategies.
Results can differ in backtest compared to real-time also. See information on this here.
http://www.ninjatrader-support.com/HelpGuideV6/DiscrepanciesReal-TimeVsBacktest.html
MONTERO
09-25-2007, 02:19 PM
The trades in the trade tab does not necessarily reflect the backtest.
Then what is the purpose of the trade tab?:confused:
The performance stats of in the "Performance" tab reflects the executions in the account. A backtest reflects executions within the strategy.
I do not understand what you are explaining. The performance tab is for the live account?
The account could have executions generated outside of the strategy or, generated by multiple strategies.
I am only running one strategy that executes on bar close so why would there be executions outside the strategy if I only want the strategy to create the executions?
I have already read the document for backtesting. Since my strategy only executes on bar close there should be no issue.
Thanks for your help:)
NinjaTrader_Ray
09-25-2007, 02:32 PM
Performance tab - Generates performance on an account
Strategy Analyzer - Generates performance on a strategy
- An account holds all executions for an account
- A strategy only holds executions for that strategy which can be a subset of the executions contained in an account
In NT 6.5 we have enhanced this so reports can be generated for an account or for a NinjaScript strategy.
Also, you can not compare a backtest results to real-time chart results. There are many variables especially if you are dealing with volume based charts that can render the results different.
MONTERO
09-25-2007, 02:49 PM
:confused:So if you created a multi-timeframe strategy that executes on bar close and you wanted to optimize the time interval settings so you could have it auto trade for you and make a lot of money how would you verify your setup is optimal?
Thanks
NinjaTrader_Ray
09-25-2007, 02:56 PM
For clarification on my end:
- Time interval --> Are you referring to bar interval such as 100 volume vs 1000 volume bar charts?
- If yes, how would you go about optimizing these values since NT does not support optimization on bar intervals.
Thanks in advance.
MONTERO
09-25-2007, 03:50 PM
Yes, I have (for example) a strategy that trades off a 100vol and refers to a 200tick and a 1000vol chart. I have been trying to find the right combination of numbers like 110v 220t 1200v or would it yeild better with 120v 240t 1230v? I have been changing these variables in backtest and recording the results. One day I decided to compare one weeks of back test to the strategy applied to a regular chart with same setup. The results were grossly different.:eek:
I have re-proved this many many times with never a match. Sooo do I go with the results from manually calculating the trades in the chart or do I go with the results from the backtest to determine the best combination? So that in the future when I apply the perfected high yeilding strategy to a live trading chart it will continue the great trend.:o
If I do not use the results from the very convenient back test to help me tweak the numbers then what good is the back test feature for anyone if the data is not valid?
Thanks
NinjaTrader_Ray
09-25-2007, 03:54 PM
I see, you manually changed interval settings and re-ran the backtest results.
Please refer back to my original link of why results can be different.
http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?DiscrepanciesReal-TimeVsBacktest
Look at the very bottom and you will see a link to "chart bars are built". Tick based bar intervals (Volume, Tick and Seconds) will produce different charts based on the range and session start/end times. This is where the discrepenancy likely comes into play.
MONTERO
09-25-2007, 04:55 PM
So the data from the live (stand alone) chart is from Zen-fire and the data from back testing is not?
:confused: How would you perfect your strategy setup then???
The results from chart and backtest can vary as much as +$400 to -$322 for the same day. I can understand a minor discrepancy of some ticks carrying over to another bar but I just doesn't seem logical to have such a wide gap.
How would you, NinjaTrader_Ray, perfect your strategy setup then???
Help I'm sinking.
Montero
NinjaTrader_Ray
09-25-2007, 05:44 PM
I can't comment if the data in real-time is different than what your backtesting against. If it is from the same data source then it should be the same.
I think you underestimate what a minor difference can do to a strategy. If your strategy is that sensitive, one could argue that its not robust. A minor difference in one bar can preclude one very profitable trade that can throw off your performance in a single day.
- If the underlying data set is different, you will get different performance results
- If the underlying data is identical (same number of bars, same start time and end time etc..) and the strategy produces different results ---> Then there is a NT logic issue that we will need to correct
MONTERO
09-25-2007, 05:53 PM
I will do some research for a single day and compare each bar in back test and on the chart to see if there are differences bar by bar.
richa61416
09-25-2007, 05:58 PM
Montero, I would recommend that you record realtime data, to test against any strategy tester results. Your hand recorded testing of your strategy, also fails to take into account slippage especially on the ER2.
Also, you can test you strategy on real time data, then run the backtester for that day, to see what it generates.
What is key however, is to ensure that the property setting on the chart, is the same as the session start and end times for the period you are backtesting. If you are using trailing stops also, I find that they appear much better in backtesting that in reality.
NinjaTrader_Ray
09-25-2007, 06:05 PM
I should have added to my last comment that this is true for historical data only. A strategy running in real-time (Sim101 or a live brokerage account) will for sure produce different results than a historical backtest.
how would you go about optimizing these values since NT does not support optimization on bar intervals?
The way I've been doing it is in the attachment.
I defined a parameter called BarsPerPeriod, and it may be used to select any time frame and may be varied by the Optimizer.
For more info, the file actually is commented -- let me know if its adequate to your understanding.
Best regards,
KBJ
NinjaTrader_Dierk
10-01-2007, 03:25 PM
Sorry what you're trying does not work. NT is not designed to take an "BarsPeriod" parameter in the Initialize method to run it by the optimizer.
It may appear so, but it will not work and you will hit the wall "here or there". We recommend not trying that.
Note: Fixed "BarsPeriod" values are fine.
richa61416
10-01-2007, 07:48 PM
Yup. Dierk is right. When it come to determining whether your strategy would work best on a different time frame, Ninja trader cannot help you with that, You actually have to input them yourself, and then optimize on different parameters for your indicators.