I have been testing this further and I think I have found what the problem relates to but I cannot make sense of it … Here is a detailed account of this.
If I run these two systems on a chart set to a small number of units/bars, then the backtest matches the Live trades. If the chart has more units, the backtest shows trades that were triggered earlier in the day, but which were not triggered in the Live trading. The cutoff point where the chart backtest either shows the earlier trades or does not is just under 67,000 units/bars.
Does this have something to do with DEFPARAM PreLoadBars?
- The chart is a 5 second chart.
- The longest (multiple) timeframe used in the code is 4 hours. This is 14,400 seconds (4*60*60), which is 2,880 bars (14,400 / 5 sec underlying chart timeframe)
- The code has DEFPARAM PreLoadBars set at 10000
So DEFPARAM PreLoadBars should comfortably cover the 4 hour timeframe and the number of units the chart is set to should not make a difference.
The only other piece of code that could possibly relate to this is as below
timeframe(60 second, updateonclose)
MOMT=ExponentialAverage[20](close-close[21])
My calculation is that this requires 5,040 bars preloaded
- 60sec / 5sec per bar to get the 60 sec timeframe = 12
- 20 bars to calc the exponential avg
- 21 bars to calc the momentum
- 12 x 20 x 21 = 5,040
As far as I can make out, If DEFPARAM PreLoadBars = 10000 means 10,000 5 second bars will be preloaded, then the above anomalies should not be happening.
Or maybe it is the case that DEFPARAM PreLoadBars in a 5 second chart is actually calculated on a 1 second basis … if that’s the problem then why can’t I find an explaination of this anywhere?
But even then, the cut-of point on the charts .. i.e. where the earlier trades show or do not show, is just under 67,000 units/bars. When the chart has 66,500 units/bars the earlier trades do not show, when the chart has 67,000 units, the earlier trades show. DEFPARAM would not be relevant here, so what’s behind these anomolies?
And even then, it does not make sense of the But it is the only explaination I can come up with.
Am I missing something here? Any input on this would be gratefully received.