Backtest Data Timeframe Weekly But Market Filter Daily.

Gday, I am backtesting a strategy with the Data Timeframe set to weekly and have 4 entry criteria ANDed. All works well except one of the entry conditions is a market filter on the XJO which is an EMA crossover using daily data. The strategy clearly enters positions when the market filter should be false. Verified by looking at the purchase dates on a chart with the 2 EMAs in place. Any ideas appreciated?

Regards

Evan

Market Filter below.
MA1 = MA(Day(PERIODAMOUNT=1), GetData(CODE=XJO:ASX, TIMEFRAME=1 Day),BARS=8,STYLE=Exponential,CALC=CLOSE);
MA2 = MA(Day(PERIODAMOUNT=1), GetData(CODE=XJO:ASX, TIMEFRAME=1 Day),BARS=34,STYLE=Exponential,CALC=CLOSE);
MA1 > MA2

So, more information. Most buy signals are correct with the market filter, some are close to the filter being crossed, but there are a few, say 10% totally out.

Your code for the MAs seems ok, but I note that they are in a daily time frame whereas you mentioned that your backtest is in a weekly time frame.

It may be that the period mismatch is causing triggers midweek that do not fit with the weekly aspect of the strategy.

Hi,

When you are mixing time frames like this you should set the back testing time frame to the lowest level (1 Day in your example), and use script overrides for anything higher (1 Week, 1 Month, etc).

If you make this adjustment on the back test settings (so its time frame is 1 day) and adjust the scripts accordingly for that setup the results should match what you see on the chart(s).

OK thanks guys I’ll give that a shot.

I would like to clarify my knowledge of the above conversation. Is the below correct?

  • If scripts have default timeframes in the code the Signal Tester will treat all defaults equal to the "Data Timeframe" in the signal tester (for example 1 Day)
One other question, are there certain function we need to be careful with in terms of mixing timeframes? For some reason I recall an article that mentioned to be carefull with RRG but I may be mistaken.

Thanks for your help!!

Hi,

You are correct, if the scripts are set to use the default time frame, they will be based off of the Data Timeframe selected in the Signal Testers properties.

When mixing time frames you need to be careful the system doesn’t cheat by referencing Fridays data before it was actually available. I believe this is the article you were referring to with discusses it in more detail:

https://www.optuma.com/the-danger-of-weekly-scripting/