Multiple Time Frames

Best trading strategies that rely on technical analysis might take into account price action on multiple time frames. This tutorial will show how to do that with, offloading most of the work to pandas resampling. It is assumed you're already familiar with basic framework usage.

We will put to the test this long-only, supposed 400%-a-year trading strategy, which uses daily and weekly relative strength index (RSI) values and moving averages (MA).

In practice, one should use functions from an indicator library, such as TA-Lib or Tulipy, but among us, let's introduce the two indicators we'll be using.

The strategy roughly goes like this:

Buy a position when:

Close the position when:

We need to provide bars data in the lowest time frame (i.e. daily) and resample it to any higher time frame (i.e. weekly) that our strategy requires.

Let's see how our strategy fares replayed on nine years of Google stock data.

Meager four trades in the span of nine years and with zero return? How about if we optimize the parameters a bit?