RSI mean-reversion strategy. Buys when RSI dips into oversold territory, sells when overbought. Timeframe: 1h | Pairs: BTC/USDT, ETH/USDT
Timeframe
1h
Direction
Long Only
Stoploss
-5.0%
Trailing Stop
No
ROI
0m: 4.0%, 30m: 2.0%, 60m: 1.0%
Interface Version
3
Startup Candles
N/A
Indicators
1
freqtrade/freqtrade-strategies
freqtrade/freqtrade-strategies
this is an example class, implementing a PSAR based trailing stop loss you are supposed to take the `custom_stoploss()` and `populate_indicators()` parts and adapt it to your own strategy
freqtrade/freqtrade-strategies
Strategy 003 author@: Gerald Lonlas github@: https://github.com/freqtrade/freqtrade-strategies
from freqtrade.strategy import IStrategy, IntParameter
from pandas import DataFrame
import talib.abstract as ta
class RSIStrategy(IStrategy):
"""
RSI mean-reversion strategy.
Buys when RSI dips into oversold territory, sells when overbought.
Timeframe: 1h | Pairs: BTC/USDT, ETH/USDT
"""
INTERFACE_VERSION = 3
timeframe = "1h"
startup_candle_count: int = 30
minimal_roi = {
"60": 0.01,
"30": 0.02,
"0": 0.04
}
stoploss = -0.05
trailing_stop = False
process_only_new_candles = True
use_exit_signal = True
exit_profit_only = False
ignore_roi_if_entry_signal = False
buy_rsi = IntParameter(20, 40, default=30, space="buy", optimize=True)
sell_rsi = IntParameter(60, 80, default=70, space="sell", optimize=True)
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(dataframe["rsi"] < self.buy_rsi.value) &
(dataframe["volume"] > 0),
"enter_long",
] = 1
return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(dataframe["rsi"] > self.sell_rsi.value) &
(dataframe["volume"] > 0),
"exit_long",
] = 1
return dataframe