How to avoid Failures in Multiple Time Frame Trading

Programming a multiple time frame trading strategy is a great thing to do, but there are certain traps. And if you don`t know them, you might accidentally look into the future and get an over optimistic backtest result. This article gives you the needed information to avoid these traps and build valid multiple time frame trading strategies.

The Differences between Real-time and Backtest

There are some differences on how software behaves when doing a backtest or when running a live strategy. As an example, in the backtest you would be able to access all data on the chart, in real-time you can only access today’s data and the historic one. This all data in the backtest can also be the future.


The screenshot above shows a daily and a weekly chart. A simple script on the daily chart is calculating a weekly average. The same 10-bar average is shown on the weekly chart too, showing the standard moving average formula.

Have a closer look: the weekly and the daily chart both show the same current price (12.509) and the same price for the average (12.491). So everything seems to be fine.

Trap Alert!

But have a look into the history to see the trap you might fall into when programming multiple time frames trading strategies.

I marked the data of 2 weeks ago. As you can see, the weekly candle is always placed at the end of the week. But when you have a close look at the chart, you will notice that the moving average of the marked week is already drawn on the daily data at the beginning of the week. This would not be possible in real-time. Although you know the weekly average right now, you do not know what it will be on Friday at market close.

If you would already know the weekly close at the beginning of the week, you could write the following strategy. This strategy steps into the mentioned trap and unintentionally looks into the future.


This multi time frame trading strategy, running on a daily or intraday data, will buy during the week if the close on Friday is above the current close. So better don’t do it.

How to do it right

Whenever you access higher time frame data make sure that the data is already known in history. Do not access the higher time frames of real time data, as this data is still under construction (the real-time weekly candle builds up during the week).

If you want to access the higher time frame, only use the data of the last finished higher time frame. This is simply done when calling the data. Use [1] for the bar before the real-time bar.


This code will trade if today’s close is below the weekly close of last Friday. It uses the [1] logic to avoid accessing the current weekly candle, and thus will work properly both in real-time and in a backtest. This is how your multiple time frame trading strategy should look like.

Take care, take profit



Tradesignal® is a registered trademark of Tradesignal GmbH. Unauthorized use or misuse is strictly prohibited. Data by Thomson Reuters Eikon.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to this Blog