Historical data does not match real-time for TWS

Questions about MultiCharts and user contributed studies.
mattyham
Posts: 4
Joined: 04 Mar 2015
Has thanked: 1 time

Historical data does not match real-time for TWS

Postby mattyham » 04 Mar 2015

I am using MultiCharts 64 for TWS and am running a very simple automated system that takes trade entries on moving average cross-overs. After running the system in real-time over the last two days, the results were very different from the "historical" results that apparently would have been achieved. I noticed the discrepancy when I closed and then restarted MultiCharts - suddenly the data for the last two days showed far fewer moving average cross-overs than the system traded in real-time. Why is this happening? If the historical data does not represent the real-time experience, then it is truly useless. I'm not doing anything fancy here - just entering trades on moving average cross-overs on a 5 minute chart. I should also add that the extra trade entries occurred when the moving averages were compressing (i.e. market action was flat and the moving averages were right on top of each other, which led to whipsaws in real-time trading that are not reflected in the historical data after the fact).

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: Historical data does not match real-time for TWS

Postby evdl » 05 Mar 2015

In realtime, all your indicators and signals are calculated per tick unless you delay these with barstatus code. In the backtest it is calculated with the close of a bar. So if the crossover happens during the bar in reallife, the backtest will take the close of the bar. And that is where you have your difference.

If you want to get the same results or at least the closest to realtime results. you have to use barstatus to delay your code. This is only to match the results in realtime. It however is not the best solution for developping a strategy IMO. Because you deliberate slowing your code and therefor the change exist you miss the right entry or exit point. But everything of course depends on what strategy you are using. The higher the timeframe, the less problems with matching realtime with backtesting.

If you only use 1 data, you can use the barmagnifier and IOG when backtesting. But make sure you calculated all your indicators in the signal. Because only signals can use barmagnifier. If you use data2, data3. You can not use BM, because you never get realtime results unless you delay your calculatings. And the crossover of the MA is only know after the fact took place.

mattyham
Posts: 4
Joined: 04 Mar 2015
Has thanked: 1 time

Re: Historical data does not match real-time for TWS

Postby mattyham » 05 Mar 2015

Hi evdl. Thanks for replying. My code begins with the statement [IntrabarOrderGeneration = false] and buys and sells are coded to occur "next bar at market", so the signal should be taking the status of the MAs at the close of the bar and then placing orders at open of next bar.

I'm using exponential MAs - not sure if this makes a difference in terms of how the backtest calculates things versus how they are calculated in real-time.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Historical data does not match real-time for TWS

Postby MC_Prog » 05 Mar 2015

I suggest you take pictures and export data from the realtime (not reloaded) chart(s), and then after a data reload you take new pictures and do a new data export.

You can then compare the data and trading behavior in realtime vs. the backtest on the reload.

tc12345
Posts: 13
Joined: 01 Nov 2010
Has thanked: 1 time
Been thanked: 1 time

Re: Historical data does not match real-time for TWS

Postby tc12345 » 06 Mar 2015

I do not think MultiCharts has moved forward on this.
viewtopic.php?f=1&t=9730&hilit=ntp


Return to “MultiCharts”