# 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 backtesting.py, 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:

• weekly RSI(30) $\geq$ daily RSI(30) $>$ 70
• Close $>$ MA(10) $>$ MA(20) $>$ MA(50) $>$ MA(100)

Close the position when:

• Daily close is more than 2% below MA(10)
• 8% fixed stop loss is hit

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?