💬 Forum

ZaratustraV19

remiotore/ccxt-freqtrade/strategies/ZaratustraV19.py · ★3 · ⑂2 · first seen 2026-07-16 · repo updated 2026-01-11

Basics mode: futures timeframe: 5m interface version: 3
Settings stoploss: -0.2 has minimal roi trailing protections
Indicators ADX ATR Bollinger_Bands talib technical
Concepts ml risk_management trailing
Other ml scikit-learn
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 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# flake8: noqa: F401
# isort: skip_file
# --- Do not remove these imports ---
from freqtrade.strategy import IStrategy
from datetime import datetime
from pandas import DataFrame
from typing import Dict, List
import talib.abstract as ta
from technical import qtpylib
from sklearn.preprocessing import MinMaxScaler



class ZaratustraV19(IStrategy):
    # Parameters
    INTERFACE_VERSION = 3
    timeframe = '5m'
    can_short = True
    use_exit_signal = False
    exit_profit_only = True
    
    # ROI table:
    
    minimal_roi = {
        "0": 0.5,
        "60": 0.45,
        "120": 0.4,
        "240": 0.3,
        "360": 0.25,
        "720": 0.2,
        "1440": 0.15,
        "2880": 0.1,
        "3600": 0.05,
        "7200": 0.02,
    }

    # Stoploss:
    stoploss = -0.20

    # Trailing stop:
    trailing_stop = True
    trailing_stop_positive = 0.013
    trailing_stop_positive_offset = 0.050
    trailing_only_offset_is_reached = True

    # Max Open Trades:
    max_open_trades = 10

    @property
    def protections(self):
        return [
            {
                "method": "CooldownPeriod",
                "stop_duration_candles": 6
            },
            {
                "method": "LowProfitPairs",
                "lookback_period_candles": 6,
                "trade_limit": 2,
                "stop_duration_candles": 60,
                "required_profit": 0.02
            },
            {
                "method": "LowProfitPairs",
                "lookback_period_candles": 24,
                "trade_limit": 4,
                "stop_duration_candles": 2,
                "required_profit": 0.01
            }
        ]

    @property
    def plot_config(self):
        plot_config = {}
        plot_config['main_plot'] = {
            'tsf' : { 'color' : 'black' },
            'max' : { 'color' : 'green' },
            'min' : { 'color' : 'red' },

        }
        plot_config['subplots'] = {
            'DI': {
                'dx' : { 'color': 'yellow' },
                'adx': { 'color': 'orange' },
                'pdi': { 'color': 'green' },
                'mdi': { 'color': 'red' },
                'atr': { 'color': 'purple' },
            },
            'Regresion' : {
                'slope' : {},
            },
        }

        return plot_config

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe['dx']    = ta.DX(dataframe)
        dataframe['adx']   = ta.ADX(dataframe)
        dataframe['pdi']   = ta.PLUS_DI(dataframe)
        dataframe['mdi']   = ta.MINUS_DI(dataframe)
        dataframe['max']   = ta.MAX(dataframe)
        dataframe['min']   = ta.MIN(dataframe)
        dataframe['tsf']   = ta.TSF(dataframe)
        dataframe['atr']   = MinMaxScaler(feature_range=(0, 100)).fit_transform(ta.ATR(dataframe).values.reshape(-1, 1))
        dataframe['slope'] = ta.LINEARREG_SLOPE(dataframe)

        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']
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        ########################
        # Min & Max Conditions #
        ########################

        dataframe.loc[
            (
                qtpylib.crossed_above(dataframe['close'], dataframe['max'].shift(1)) &
                (dataframe['slope'] > dataframe['slope'].shift(1)) &
                (dataframe['slope'] > 0)
            ),
            ['enter_long', 'enter_tag']
        ] = (1, 'Long Max enter')

        dataframe.loc[
            (
                qtpylib.crossed_below(dataframe['close'], dataframe['min'].shift(1)) &
                (dataframe['slope'] < dataframe['slope'].shift(1)) &
                (dataframe['slope'] < 0)
            ),
            ['enter_short', 'enter_tag']
        ] = (1, 'Short Min enter')

        ##############################
        # Bollinger Bands Conditions #
        ##############################

        dataframe.loc[
            (
                qtpylib.crossed_above(dataframe['close'], dataframe['bb_upperband']) &
                (dataframe['slope'] > dataframe['slope'].shift(1)) &
                (dataframe['slope'] > 0)
            ),
            ['enter_long', 'enter_tag']
        ] = (1, 'Long Bollinger enter')

        dataframe.loc[
            (
                qtpylib.crossed_below(dataframe['close'], dataframe['bb_lowerband']) &
                (dataframe['slope'] < dataframe['slope'].shift(1)) &
                (dataframe['slope'] < 0)
            ),
            ['enter_short', 'enter_tag']
        ] = (1, 'Short Bollinger enter')

        ##################################
        # TimeSeries Forecast Conditions #
        ##################################

        dataframe.loc[
            (
                qtpylib.crossed_above(dataframe['close'], dataframe['tsf']) &
                (dataframe['slope'] > dataframe['slope'].shift(1)) &
                (dataframe['slope'] > 0)
            ),
            ['enter_long', 'enter_tag']
        ] = (1, 'Long TimeSeries Forecast enter')

        dataframe.loc[
            (
                qtpylib.crossed_below(dataframe['close'], dataframe['tsf']) &
                (dataframe['slope'] < dataframe['slope'].shift(1)) &
                (dataframe['slope'] < 0)
            ),
            ['enter_short', 'enter_tag']
        ] = (1, 'Short TimeSeries Forecast enter')

        ####################################
        # Directional Indicator Conditions #
        ####################################

        dataframe.loc[
            (
                (dataframe['dx']  > dataframe['mdi']) &
                (dataframe['adx'] > dataframe['mdi']) &
                (dataframe['pdi'] > dataframe['mdi']) &
                (dataframe['atr'] > dataframe['mdi']) &
                (dataframe['slope'] > dataframe['slope'].shift(1)) &
                (dataframe['slope'] > 0)
            ),
            ['enter_long', 'enter_tag']
        ] = (1, 'Long DI enter')

        dataframe.loc[
            (
                (dataframe['dx']  > dataframe['pdi']) &
                (dataframe['adx'] > dataframe['pdi']) &
                (dataframe['mdi'] > dataframe['pdi']) &
                (dataframe['atr'] > dataframe['pdi']) &
                (dataframe['slope'] < dataframe['slope'].shift(1)) &
                (dataframe['slope'] < 0)
            ),
            ['enter_short', 'enter_tag']
        ] = (1, 'Short DI enter')
        
        return dataframe
    
    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        return dataframe
    
    def leverage(self, pair: str, current_time: datetime, current_rate: float, proposed_leverage: float, max_leverage: float, side: str, **kwargs,) -> float:
        return 10