Multi-Timeframe RSI Entries and Exits with a Trend Filter
Summary
This five-minute Freqtrade strategy calculates RSI on the base timeframe and on two resampled, slower intervals. It also computes short and long simple moving averages. A long entry is triggered when the shorter average is at or above the longer average and base-timeframe RSI is sufficiently below the slower interval RSI. The exit condition triggers when base RSI rises above both resampled RSI readings.
The configuration specifies a small fixed return-on-investment target and a five percent stop loss. The code forward-fills merged resampled indicators for use on the base timeframe. No backtest results, asset universe, or execution analysis are provided, so the stated settings are code parameters rather than evidence of profitability. The entry's RSI comparison is a relative oversold condition, and its moving-average filter should be interpreted as coded rather than as a general confirmation of bearishness.
Key ideas
- The strategy compares RSI across the base timeframe and two slower resampled timeframes.
- Long entries require the short simple moving average to be at least the long average and base RSI to be notably lower than the slowest RSI.
- An exit is signaled when base RSI exceeds both resampled RSI values.
- The configuration includes a fixed stop loss and a minimal ROI target.
- The document supplies strategy code but no reported performance results.
Tags
Full text
# MultiRSI
# MultiRSI
author@: Gert Wohlgemuth
based on work from Creslin
## Source (GPL-3.0)
```python
# --- Do not remove these libs ---
from freqtrade.strategy import IStrategy
from pandas import DataFrame
# --------------------------------
import talib.abstract as ta
from technical.util import resample_to_interval, resampled_merge
class MultiRSI(IStrategy):
"""
author@: Gert Wohlgemuth
based on work from Creslin
"""
INTERFACE_VERSION: int = 3
minimal_roi = {
"0": 0.01
}
# Optimal stoploss designed for the strategy
stoploss = -0.05
# Optimal timeframe for the strategy
timeframe = '5m'
def get_ticker_indicator(self):
return int(self.timeframe[:-1])
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe['sma5'] = ta.SMA(dataframe, timeperiod=5)
dataframe['sma200'] = ta.SMA(dataframe, timeperiod=200)
# resample our dataframes
dataframe_short = resample_to_interval(dataframe, self.get_ticker_indicator() * 2)
dataframe_long = resample_to_interval(dataframe, self.get_ticker_indicator() * 8)
# compute our RSI's
dataframe_short['rsi'] = ta.RSI(dataframe_short, timeperiod=14)
dataframe_long['rsi'] = ta.RSI(dataframe_long, timeperiod=14)
# merge dataframe back together
dataframe = resampled_merge(dataframe, dataframe_short)
dataframe = resampled_merge(dataframe, dataframe_long)
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
dataframe.ffill(inplace=True)
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
# must be bearish
(dataframe['sma5'] >= dataframe['sma200']) &
(dataframe['rsi'] < (dataframe['resample_{}_rsi'.format(self.get_ticker_indicator() * 8)] - 20))
),
'enter_long'] = 1
return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe['rsi'] > dataframe['resample_{}_rsi'.format(self.get_ticker_indicator()*2)]) &
(dataframe['rsi'] > dataframe['resample_{}_rsi'.format(self.get_ticker_indicator()*8)])
),
'exit_long'] = 1
return dataframe
```Shown in full with attribution under the source's licence. Licence: GPL-3.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.