💬 Forum

strategy_v2

freqle/uploads/user-90abf0da8f3178f3/strategy_v2_converted.py · first seen 2026-07-28

Basics mode: spot timeframe: 5m interface version: 3 outdated
Settings stoploss: -0.03 has minimal roi
Indicators Bollinger_Bands CCI EMA MFI RSI SMA Stochastic Williams_R talib technical
15 related strategies ( identical code, similar name)

Each tile is a different kind of check — from an instant code lint to full sandboxed backtests and forward tests on recent data. Not sure what a check actually proves? See the FAQ →

Source

Download v3 on request Raw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
from freqtrade.strategy.interface import IStrategy
from technical.indicator_helpers import fishers_inverse
import freqtrade.vendor.qtpylib.indicators as qtpylib
from pandas import DataFrame, DatetimeIndex, merge
import numpy  # noqa
import talib.abstract as ta

class strategy_v2(IStrategy):
    INTERFACE_VERSION = 3
    minimal_roi = {}
    stoploss = -0.15
    timeframe = '5m'

    def get_ticker_indicator(self):
        return int(self.ticker_interval[:-1])

    def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
        from technical.util import resample_to_interval
        from technical.util import resampled_merge
        dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
        dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
        dataframe['ema200'] = ta.EMA(dataframe, timeperiod=200)
        dataframe_short = resample_to_interval(dataframe, self.get_ticker_indicator() * 3)
        dataframe_long = resample_to_interval(dataframe, self.get_ticker_indicator() * 7)
        dataframe_short['rsi'] = ta.RSI(dataframe_short, timeperiod=14)
        dataframe_long['rsi'] = ta.RSI(dataframe_long, timeperiod=14)
        dataframe = resampled_merge(dataframe, dataframe_short)
        dataframe = resampled_merge(dataframe, dataframe_long)
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        dataframe.fillna(method='ffill', inplace=True)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame) -> DataFrame:
        dataframe.loc[(dataframe['ema50'] >= dataframe['ema200']) & (dataframe['rsi'] < dataframe['rsi_y'] - 20) & (dataframe['rsi'] != 0) & (dataframe['rsi_x'] != 0), 'enter_long'] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame) -> DataFrame:
        dataframe.loc[(dataframe['rsi'] > dataframe['rsi_x']) & (dataframe['rsi'] > dataframe['rsi_y']) | (dataframe['rsi'] > 90) & (dataframe['rsi_x'] > 90), 'exit_long'] = 1
        return dataframe

class StrategyV3(IStrategy):
    INTERFACE_VERSION = 3
    minimal_roi = {'1440': 0.2}
    stoploss = -0.15
    timeframe = '15m'

    def get_ticker_indicator(self):
        return int(self.ticker_interval[:-1])

    def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
        from technical.util import resample_to_interval
        from technical.util import resampled_merge
        dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
        dataframe['ema3'] = ta.EMA(dataframe, timeperiod=3)
        dataframe['ema5'] = ta.EMA(dataframe, timeperiod=5)
        dataframe['ema10'] = ta.EMA(dataframe, timeperiod=10)
        dataframe['ema20'] = ta.EMA(dataframe, timeperiod=20)
        dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
        dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)
        dataframe['ema200'] = ta.EMA(dataframe, timeperiod=200)
        stoch = ta.STOCH(dataframe, fastk_period=5, slowk_period=2, slowk_matype=0, slowd_period=2, slowd_matype=0)
        dataframe['slowd15'] = stoch['slowd']
        dataframe['slowk15'] = stoch['slowk']
        stoch = ta.STOCH(dataframe, fastk_period=10, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0)
        dataframe['slowd'] = stoch['slowd']
        dataframe['slowk'] = stoch['slowk']
        stoch_fast = ta.STOCHF(dataframe)
        dataframe['fastd'] = stoch_fast['fastd']
        dataframe['fastk'] = stoch_fast['fastk']
        dataframe['minus_di'] = ta.MINUS_DI(dataframe, timeperiod=24)
        dataframe['plus_di'] = ta.PLUS_DI(dataframe, timeperiod=24)
        dataframe['blower'] = ta.BBANDS(dataframe, nbdevup=2, nbdevdn=2)['lowerband']
        bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
        dataframe['bb_lowerband'] = bollinger['lower']
        dataframe['bb_middleband'] = bollinger['mid']
        dataframe['bb_upperband'] = bollinger['upper']
        dataframe['sma3'] = ta.SMA(dataframe, timeperiod=3)
        dataframe['sma5'] = ta.SMA(dataframe, timeperiod=5)
        dataframe['sma10'] = ta.SMA(dataframe, timeperiod=10)
        dataframe['sma20'] = ta.SMA(dataframe, timeperiod=20)
        dataframe['sma50'] = ta.SMA(dataframe, timeperiod=50)
        dataframe['sma100'] = ta.SMA(dataframe, timeperiod=100)
        dataframe['sma220'] = ta.SMA(dataframe, timeperiod=220)
        dataframe['sma200'] = ta.SMA(dataframe, timeperiod=200)
        dataframe['willr'] = ta.WILLR(dataframe, timeperiod=28)
        dataframe_short = resample_to_interval(dataframe, self.get_ticker_indicator() * 3)
        dataframe_long = resample_to_interval(dataframe, self.get_ticker_indicator() * 7)
        dataframe_short['rsi'] = ta.RSI(dataframe_short, timeperiod=14)
        dataframe_long['rsi'] = ta.RSI(dataframe_long, timeperiod=14)
        dataframe['cci'] = ta.CCI(dataframe, timeperiod=20)
        dataframe['mfi'] = ta.MFI(dataframe)
        dataframe['CDLHAMMER'] = ta.CDLHAMMER(dataframe)
        dataframe = resampled_merge(dataframe, dataframe_short)
        dataframe = resampled_merge(dataframe, dataframe_long)
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        dataframe.fillna(method='ffill', inplace=True)
        dataframe['fisher_rsi'] = fishers_inverse(dataframe['rsi'])
        dataframe['fisher_rsi_norma'] = 50 * (dataframe['fisher_rsi'] + 1)
        dataframe['resample_rsi_2'] = dataframe['resample_{}_rsi'.format(self.get_ticker_indicator() * 3)]
        dataframe['resample_rsi_8'] = dataframe['resample_{}_rsi'.format(self.get_ticker_indicator() * 7)]
        dataframe['average'] = (dataframe['close'] + dataframe['open'] + dataframe['high'] + dataframe['low']) / 4
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame) -> DataFrame:
        dataframe.loc[(dataframe['ema50'] >= dataframe['ema200']) & (dataframe['rsi'] < dataframe['resample_{}_rsi'.format(self.get_ticker_indicator() * 7)] - 20) & (dataframe['rsi'] != 0) & (dataframe['resample_{}_rsi'.format(self.get_ticker_indicator() * 3)] != 0), 'enter_long'] = 1
        print(dataframe['rsi'])
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame) -> DataFrame:
        dataframe.loc[(dataframe['rsi'] > dataframe['resample_rsi_2']) & (dataframe['rsi'] > dataframe['resample_rsi_8']) | (dataframe['rsi'] > 90) & (dataframe['resample_rsi_2'] > 90), 'exit_long'] = 1
        print(dataframe['rsi'])
        return dataframe

class StrategyV4(IStrategy):
    INTERFACE_VERSION = 3
    minimal_roi = {'60': 0.01, '30': 0.03, '20': 0.04, '0': 0.05}
    stoploss = -0.03
    timeframe = '5m'

    def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
        """
        Adds several different TA indicators to the given DataFrame
        Performance Note: For the best performance be frugal on the number of indicators
        you are using. Let uncomment only the indicator you are using in your strategies
        or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
        """
        stoch_5 = ta.STOCH(dataframe, fastk_period=9, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0)
        stoch_15 = ta.STOCH(dataframe, fastk_period=27, slowk_period=9, slowk_matype=0, slowd_period=9, slowd_matype=0)
        dataframe['slowd_5'] = stoch_5['slowd']
        dataframe['slowk_5'] = stoch_5['slowk']
        dataframe['slowd_15'] = stoch_15['slowd']
        dataframe['slowk_15'] = stoch_15['slowk']
        dataframe['stochJ_5'] = 3 * dataframe['slowk_5'] - 2 * dataframe['slowd_5']
        dataframe['stochJ_15'] = 3 * dataframe['slowk_15'] - 2 * dataframe['slowd_15']
        stoch_fast = ta.STOCHF(dataframe)
        dataframe['fastd'] = stoch_fast['fastd']
        dataframe['fastk'] = stoch_fast['fastk']
        dataframe['rsi'] = ta.RSI(dataframe)
        rsi = 0.1 * (dataframe['rsi'] - 50)
        dataframe['fisher_rsi'] = (numpy.exp(2 * rsi) - 1) / (numpy.exp(2 * rsi) + 1)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame) -> DataFrame:
        """
        Based on TA indicators, populates the buy signal for the given dataframe
        :param dataframe: DataFrame
        :return: DataFrame with buy column
        """
        dataframe.loc[(dataframe['rsi'] < 45) & (dataframe['slowk_15'] > dataframe['slowd_15']) & (dataframe['slowk_15'] < 50) & (dataframe['slowk_5'] < 25) & (dataframe['stochJ_5'] > dataframe['slowd_5']) & (dataframe['fastk'] > dataframe['fastd']) & (dataframe['fastk'] >= 0) & (dataframe['fastk'] < 50), 'enter_long'] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame) -> DataFrame:
        """
        Based on TA indicators, populates the sell signal for the given dataframe
        :param dataframe: DataFrame
        :return: DataFrame with buy column
        """
        dataframe.loc[(dataframe['stochJ_15'] >= 100) & (dataframe['fisher_rsi'] >= 0.8) & (dataframe['fastk'] >= 100), 'exit_long'] = 1
        return dataframe