7 related strategies (⧉ identical code, ≈ similar name)
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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | import logging import numpy as np import pandas as pd from technical import qtpylib, pivots_points from pandas import DataFrame from datetime import datetime, timezone from typing import Optional from functools import reduce import talib.abstract as ta import pandas_ta as pta from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter, IStrategy, IntParameter, RealParameter, merge_informative_pair) import freqtrade.vendor.qtpylib.indicators as qtpylib from freqtrade.persistence import Trade logger = logging.getLogger(__name__) class thetank4TV(IStrategy): ### Strategy parameters ### exit_profit_only = True ### No selling at a loss use_custom_stoploss = True trailing_stop = True position_adjustment_enable = True ignore_roi_if_entry_signal = True use_exit_signal = True stoploss = -0.09 startup_candle_count: int = 30 timeframe = '15m' # DCA Parameters position_adjustment_enable = True max_entry_position_adjustment = 0 max_dca_multiplier = 1 minimal_roi = { "12000": 0.01, "2400": 0.10, "300": 0.15, "180": 0.30, "120":0.40, "60": 0.45, "0": 0.50 } ### Hyperoptable parameters ### # entry optizimation max_epa = CategoricalParameter([0, 1], default=0, space="buy", optimize=True) # protections cooldown_lookback = IntParameter(4, 48, default=16, space="protection", optimize=True) stop_duration = IntParameter(5, 96, default=5, space="protection", optimize=True) use_stop_protection = BooleanParameter(default=True, space="protection", optimize=True) # indicators wavelength = IntParameter(low=3, high=10, default=8, space='buy', optimize=True) crosslength = IntParameter(low=3, high=10, default=3, space='sell', optimize=True) filterlength = IntParameter(low=15, high=35, default=25, space='buy', optimize=True) # trading buy_rsi = IntParameter(low=20, high=35, default=25, space='buy', optimize=True, load=True) buy_rsi_bear = IntParameter(low=40, high=55, default=45, space='buy', optimize=True, load=True) buy_rsi_bull = IntParameter(low=40, high=75, default=65, space='buy', optimize=True, load=True) buy_wt_bear = IntParameter(low=20, high=55, default=45, space='buy', optimize=True, load=True) buy_wt_bull = IntParameter(low=30, high=75, default=65, space='buy', optimize=True, load=True) sell_rsi = IntParameter(low=50, high=80, default=55, space='sell', optimize=True, load=True) # dca level optimization dca1 = DecimalParameter(low=0.03, high=0.08, decimals=2, default=0.05, space='buy', optimize=True, load=True) # dca2 = DecimalParameter(low=0.08, high=0.15, decimals=2, default=0.10, space='buy', optimize=True, load=True) # dca3 = DecimalParameter(low=0.15, high=0.25, decimals=2, default=0.15, space='buy', optimize=True, load=True) #trailing stop loss optimiziation tsl_target5 = DecimalParameter(low=0.2, high=0.4, decimals=1, default=0.3, space='sell', optimize=True, load=True) ts5 = DecimalParameter(low=0.04, high=0.06, default=0.05, space='sell', optimize=True, load=True) tsl_target4 = DecimalParameter(low=0.18, high=0.3, default=0.2, space='sell', optimize=True, load=True) ts4 = DecimalParameter(low=0.03, high=0.05, default=0.045, space='sell', optimize=True, load=True) tsl_target3 = DecimalParameter(low=0.10, high=0.15, default=0.15, space='sell', optimize=True, load=True) ts3 = DecimalParameter(low=0.025, high=0.04, default=0.035, space='sell', optimize=True, load=True) tsl_target2 = DecimalParameter(low=0.07, high=0.12, default=0.1, space='sell', optimize=True, load=True) ts2 = DecimalParameter(low=0.015, high=0.03, default=0.02, space='sell', optimize=True, load=True) tsl_target1 = DecimalParameter(low=0.05, high=0.06, default=0.07, space='sell', optimize=True, load=True) ts1 = DecimalParameter(low=0.01, high=0.016, default=0.013, space='sell', optimize=True, load=True) tsl_target0 = DecimalParameter(low=0.02, high=0.05, default=0.03, space='sell', optimize=True, load=True) ts0 = DecimalParameter(low=0.008, high=0.015, default=0.013, space='sell', optimize=True, load=True) ### protections ### @property def protections(self): prot = [] prot.append({ "method": "CooldownPeriod", "stop_duration_candles": self.cooldown_lookback.value }) if self.use_stop_protection.value: prot.append({ "method": "StoplossGuard", "lookback_period_candles": 24 * 3, "trade_limit": 1, "stop_duration_candles": self.stop_duration.value, "only_per_pair": False }) return prot ### Dollar Cost Averaging ### # This is called when placing the initial order (opening trade) def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float, proposed_stake: float, min_stake: Optional[float], max_stake: float, leverage: float, entry_tag: Optional[str], side: str, **kwargs) -> float: # if self.max_epa.value == 0: # self.max_dca_multiplier = 1 # elif self.max_epa.value == 1: # self.max_dca_multiplier = 2 # elif self.max_epa.value == 2: # self.max_dca_multiplier = 3 # else: # self.max_dca_multiplier = 4 # We need to leave most of the funds for possible further DCA orders # This also applies to fixed stakes return proposed_stake / self.max_dca_multiplier def adjust_trade_position(self, trade: Trade, current_time: datetime, current_rate: float, current_profit: float, min_stake: Optional[float], max_stake: float, current_entry_rate: float, current_exit_rate: float, current_entry_profit: float, current_exit_profit: float, **kwargs) -> Optional[float]: """ Custom trade adjustment logic, returning the stake amount that a trade should be increased or decreased. This means extra buy or sell orders with additional fees. Only called when `position_adjustment_enable` is set to True. For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/ When not implemented by a strategy, returns None :param trade: trade object. :param current_time: datetime object, containing the current datetime :param current_rate: Current buy rate. :param current_profit: Current profit (as ratio), calculated based on current_rate. :param min_stake: Minimal stake size allowed by exchange (for both entries and exits) :param max_stake: Maximum stake allowed (either through balance, or by exchange limits). :param current_entry_rate: Current rate using entry pricing. :param current_exit_rate: Current rate using exit pricing. :param current_entry_profit: Current profit using entry pricing. :param current_exit_profit: Current profit using exit pricing. :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. :return float: Stake amount to adjust your trade, Positive values to increase position, Negative values to decrease position. Return None for no action. """ if current_profit > 0.10 and trade.nr_of_successful_exits == 0: # Take half of the profit at +5% return -(trade.stake_amount / 2) if current_profit > -(self.dca1.value) and trade.nr_of_successful_entries == 1: return None # if current_profit > -(self.dca2.value) and trade.nr_of_successful_entries == 2: # return None # if current_profit > -(self.dca3.value) and trade.nr_of_successful_entries == 3: # return None # Obtain pair dataframe (just to show how to access it) dataframe, _ = self.dp.get_analyzed_dataframe(trade.pair, self.timeframe) filled_entries = trade.select_filled_orders(trade.entry_side) count_of_entries = trade.nr_of_successful_entries # Allow up to 3 additional increasingly larger buys (4 in total) # Initial buy is 1x # If that falls to -2.5% profit, we buy more, # If that falls down to -5% again, we buy 1.5x more # If that falls once again down to -5%, we buy more # Total stake for this trade would be 1 + 1.5 + 2 + 2.5 = 7x of the initial allowed stake. # That is why max_dca_multiplier is 7 # Hope you have a deep wallet! try: # This returns first order stake size stake_amount = filled_entries[0].cost # This then calculates current safety order size if count_of_entries == 1: stake_amount = stake_amount * 1 elif count_of_entries == 2: stake_amount = stake_amount * 1 elif count_of_entries == 3: stake_amount = stake_amount * 1 else: stake_amount = stake_amount return stake_amount except Exception as exception: return None return None ### Trailing Stop ### def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime, current_rate: float, current_profit: float, **kwargs) -> float: for stop5 in self.tsl_target5.range: if (current_profit > stop5): for stop5a in self.ts5.range: return stop5a for stop4 in self.tsl_target4.range: if (current_profit > stop4): for stop4a in self.ts4.range: return stop4a for stop3 in self.tsl_target3.range: if (current_profit > stop3): for stop3a in self.ts3.range: return stop3a for stop2 in self.tsl_target2.range: if (current_profit > stop2): for stop2a in self.ts2.range: return stop2a for stop1 in self.tsl_target1.range: if (current_profit > stop1): for stop1a in self.ts1.range: return stop1a for stop0 in self.tsl_target0.range: if (current_profit > stop0): for stop0a in self.ts0.range: return stop0a return self.stoploss ### NORMAL INDICATORS ### def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # Pivot Points pivots = pivots_points.pivots_points(dataframe) dataframe['pivot'] = pivots['pivot'] dataframe['s1'] = pivots['s1'] dataframe['r1'] = pivots['r1'] dataframe['s2'] = pivots['s2'] dataframe['r2'] = pivots['r2'] dataframe['s3'] = pivots['s3'] dataframe['r3'] = pivots['r3'] dataframe['r3-dif'] = (dataframe['r3'] - dataframe['r2']) / 4 dataframe['r2.25'] = dataframe['r2'] + dataframe['r3-dif'] dataframe['r2.50'] = dataframe['r2'] + (dataframe['r3-dif'] * 2) dataframe['r2.75'] = dataframe['r2'] + (dataframe['r3-dif'] * 3) # Filter ZEMA for length in self.filterlength.range: dataframe[f'ema_1{length}'] = ta.EMA(dataframe['close'], timeperiod=length) dataframe[f'ema_2{length}'] = ta.EMA(dataframe[f'ema_1{length}'], timeperiod=length) dataframe[f'ema_dif{length}'] = dataframe[f'ema_1{length}'] - dataframe[f'ema_2{length}'] dataframe[f'zema_{length}'] = dataframe[f'ema_1{length}'] + dataframe[f'ema_dif{length}'] # RSI dataframe['rsi'] = ta.RSI(dataframe) dataframe['rsi_ma'] = ta.SMA(dataframe['rsi'], timeperiod=7) # WaveTrend using OHLC4 or HA close - 3/21 ap = (0.25 * (dataframe['high'] + dataframe['low'] + dataframe["close"] + dataframe["open"])) for wave in self.wavelength.range: dataframe[f'esa{wave}'] = ta.EMA(ap, timeperiod = wave) dataframe[f'd{wave}'] = ta.EMA(abs(ap - dataframe[f'esa{wave}']), timeperiod = wave) dataframe[f'wave_ci{wave}'] = (ap-dataframe[f'esa{wave}']) / (0.015 * dataframe[f'd{wave}']) dataframe[f'wave_t1{wave}'] = ta.EMA(dataframe[f'wave_ci{wave}'], timeperiod = 21) for cross in self.crosslength.range: dataframe[f'wave_t2{cross}_{wave}'] = ta.SMA(dataframe[f'wave_t1{wave}'], timeperiod = cross) # SMA dataframe['200_SMA'] = ta.SMA(dataframe["close"], timeperiod = 200) dataframe['30_SMA'] = ta.SMA(dataframe["close"], timeperiod = 30) dataframe['8_SMA'] = ta.SMA(dataframe["close"], timeperiod = 8) # TTM Squeeze ttm_Squeeze = pta.squeeze(high = dataframe['high'], low = dataframe['low'], close = dataframe["close"], lazybear = True) dataframe['ttm_Squeeze'] = ttm_Squeeze['SQZ_20_2.0_20_1.5_LB'] dataframe['ttm_ema'] = ta.EMA(dataframe['ttm_Squeeze'], timeperiod = 4) dataframe['squeeze_ON'] = ttm_Squeeze['SQZ_ON'] dataframe['squeeze_OFF'] = ttm_Squeeze['SQZ_OFF'] dataframe['NO_squeeze'] = ttm_Squeeze['SQZ_NO'] # Calculate the percentage change between the high and open prices for each 5-minute candle dataframe['perc_change'] = (dataframe['high'] / dataframe['open'] - 1) * 100 # Create a custom indicator that checks if any of the past 100 5-minute candles' high price is 3% or more above the open price dataframe['candle_3perc_100'] = dataframe['perc_change'].rolling(200).apply(lambda x: np.where(x >= 3, 1, 0).sum()).shift() # Create a custom indicator that checks if the price has gone up 10% or more over the last hundred candles dataframe['candle_10perc_100'] = dataframe['close'].pct_change(periods=50).shift() # Calculate the percentage of the current candle's range where the close price is dataframe['close_percentage'] = (dataframe['close'] - dataframe['low']) / (dataframe['high'] - dataframe['low']) dataframe['body_size'] = abs(dataframe['open'] - dataframe['close']) dataframe['range_size'] = dataframe['high'] - dataframe['low'] dataframe['body_range_ratio'] = dataframe['body_size'] / dataframe['range_size'] dataframe['upper_wick_size'] = dataframe['high'] - dataframe[['open', 'close']].max(axis=1) dataframe['upper_wick_range_ratio'] = dataframe['upper_wick_size'] / dataframe['range_size'] lookback_period = 10 dataframe['max_high'] = dataframe['high'].rolling(lookback_period).max() dataframe['min_low'] = dataframe['low'].rolling(lookback_period).min() dataframe['close_position'] = (dataframe['close'] - dataframe['min_low']) / (dataframe['max_high'] - dataframe['min_low']) dataframe['current_candle_perc_change'] = (dataframe['high'] / dataframe['open'] - 1) * 100 # if self.dp.runmode.value in ('live', 'dry_run'): # ticker = self.dp.ticker(metadata['pair']) # dataframe['last_price'] = ticker['last'] # dataframe['volume24h'] = ticker['quoteVolume'] # dataframe['vwap'] = ticker['vwap'] # # Trading pair: {'symbol': 'KAVA/USDT', 'timestamp': 1675451904532, 'datetime': '2023-02-03T19:18:24.532Z', # 'high': 1.0652, 'low': 1.0031, 'bid': 1.0382, 'bidVolume': None, 'ask': 1.0395, 'askVolume': None, # 'vwap': 1.035200204815235, 'open': 1.0558, 'close': 1.0403, 'last': 1.0403, 'previousClose': None, 'change': -0.0155, # 'percentage': -1.46, 'average': 1.04130553, 'baseVolume': 457210.7641, 'quoteVolume': 473304.67664005, # 'info': # {'time': 1675451904532, 'symbol': 'KAVA-USDT', 'buy': '1.0382', 'sell': '1.0395', 'changeRate': '-0.0146', 'changePrice': '-0.0155', 'high': '1.0652', 'low': '1.0031', 'vol': '457210.7641', 'volValue': '473304.67664005', 'last': '1.0403', 'averagePrice': '1.04130553', 'takerFeeRate': '0.001', 'makerFeeRate': '0.001', 'takerCoefficient': '1', 'makerCoefficient': '1'}}, self.max_epa.value: 1, self.max_dca_multiplier: 2 # if (dataframe['30_SMA'].iloc[-1] > dataframe['200_SMA'].iloc[-1] # and dataframe['30_SMA'].iloc[-1] > dataframe['30_SMA'].iloc[-2] # and dataframe['200_SMA'].iloc[-1] > dataframe['200_SMA'].iloc[-2]).all(): # self.max_epa.value = 1 # elif (dataframe['30_SMA'].iloc[-1] > dataframe['200_SMA'].iloc[-1] # and dataframe['30_SMA'].iloc[-1] > dataframe['30_SMA'].iloc[-2].all()): # self.max_epa.value = 1 # elif (dataframe['30_SMA'].iloc[-1] < dataframe['200_SMA'].iloc[-1] # and dataframe['30_SMA'].iloc[-1] > dataframe['30_SMA'].iloc[-2].all()): # self.max_epa.value = 2 # else: # self.max_epa.value = 2 # # print(f"Trading Pair: {dataframe.name}") # print(f"self.max_epa.value: {self.max_epa.value}") # print(f"self.max_dca_multiplier: {self.max_dca_multiplier}") # print(f"Trading pair: {ticker['symbol']}, max_epa: {self.max_epa.value}, dca_multiplier: {self.max_dca_multiplier}") return dataframe ### ENTRY CONDITIONS ### def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame: # df.loc[ # ( # # Signal: RSI crosses above 30 # (df['close'] > df[f'zema_{self.filterlength.value}'])& # (df['close'] < df['r2']) & # (df['squeeze_ON'] == 1)& # (df['rsi_ma'] > df['rsi_ma'].shift(1)) & # (df['200_SMA'] < df['200_SMA'].shift(1)) & # (df['rsi'] < self.buy_rsi_bear.value) & # (df[f'wave_t1{self.wavelength.value}'] < self.buy_wt_bear.value)& # (df[f'wave_t1{self.wavelength.value}'] > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # Guard: Wave 1 is raising # (qtpylib.crossed_above(df[f'wave_t1{self.wavelength.value}'], df[f'wave_t2{self.crosslength.value}_{self.wavelength.value}'])) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'ttm_Squeeze/WT - bear') # df.loc[ # ( # (df['close'] > df[f'zema_{self.filterlength.value}'])& # (df['close'] < df['r2']) & # (df['squeeze_ON'] == 1)& # (df['rsi_ma'] > df['rsi_ma'].shift(1)) & # (df['rsi'] < self.buy_rsi_bear.value) & # (df['200_SMA'] < df['200_SMA'].shift(1)) & # (df[f'wave_t1{self.wavelength.value}'] < self.buy_wt_bear.value)& # (df[f'wave_t1{self.wavelength.value}'] > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # Guard: Wave 1 is raising # (df[f'wave_t1{self.wavelength.value}'].shift(2) > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'ttm_Squeeze/WTT - bear') # df.loc[ # ( # (df['close'] > df[f'zema_{self.filterlength.value}'])& # (df['close'] < df['r2']) & # (df['rsi_ma'] > df['rsi_ma'].shift(1)) & # (df['rsi'] < self.buy_rsi_bear.value) & # (df['200_SMA'] < df['200_SMA'].shift(1)) & # (df[f'wave_t1{self.wavelength.value}'] < self.buy_wt_bear.value)& # (df[f'wave_t1{self.wavelength.value}'] > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # Guard: Wave 1 is raising # (df[f'wave_t1{self.wavelength.value}'].shift(2) > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'WT transition - bear') # df.loc[ # ( # (df['close'] > df[f'zema_{self.filterlength.value}'])& # (df['close'] < df['r2']) & # (df['200_SMA'] < df['200_SMA'].shift(1)) & # (df[f'wave_t1{self.wavelength.value}'] > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # Guard: Wave 1 is raising # (df[f'wave_t1{self.wavelength.value}'] < self.buy_wt_bear.value) & # (df[f'wave_t1{self.wavelength.value}'].shift(2) > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'WT - bear') # df.loc[ # ( # (df['close'] > df[f'zema_{self.filterlength.value}'])& # (df['close'] < df['r2']) & # (df['squeeze_ON'] == 1)& # (df['rsi_ma'] > df['rsi_ma'].shift(1)) & # (df['rsi'] < self.buy_rsi_bull.value) & # (df['200_SMA'] > df['200_SMA'].shift(1)) & # (df[f'wave_t1{self.wavelength.value}'] > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # Guard: Wave 1 is raising # (qtpylib.crossed_above(df[f'wave_t1{self.wavelength.value}'], df[f'wave_t2{self.crosslength.value}_{self.wavelength.value}'])) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'ttm_Squeeze/WT - bull') # df.loc[ # ( # (df['close'] > df[f'zema_{self.filterlength.value}'])& # (df['close'] < df['s1']) & # (df['squeeze_ON'] == 1)& # (df['rsi_ma'] > df['rsi_ma'].shift(1)) & # (df['rsi'] < self.buy_rsi_bull.value) & # (df['200_SMA'] > df['200_SMA'].shift(1)) & # (df[f'wave_t1{self.wavelength.value}'] > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # (df[f'wave_t1{self.wavelength.value}'] < self.buy_wt_bull.value) & # (df[f'wave_t1{self.wavelength.value}'].shift(2) > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # # Check if no candle high price rose more than 5% in the past 50 candles # (df['candle_3perc_100'] == 0) & # # Check if the price has not gone up 10% or more over the last hundred candles # (df['candle_10perc_100'] < 0.5) & # # Check if the high price of the current candle is not 3% or more above the open price # (df['current_candle_perc_change'] < 0.75) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'ttm_Squeeze/WTT - bull') # df.loc[ # ( # (df['close'] > df[f'zema_{self.filterlength.value}'])& # (df['close'] < df['s1']) & # (df['rsi_ma'] > df['rsi_ma'].shift(1)) & # (df['rsi'] < self.buy_rsi_bull.value) & # (df['200_SMA'] > df['200_SMA'].shift(1)) & # (df[f'wave_t1{self.wavelength.value}'] > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # Guard: Wave 1 is raising # (df[f'wave_t1{self.wavelength.value}'] < self.buy_wt_bull.value) & # (df[f'wave_t1{self.wavelength.value}'].shift(2) > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # # Check if no candle high price rose more than 5% in the past 50 candles # (df['candle_3perc_100'] == 0) & # # Check if the price has not gone up 10% or more over the last hundred candles # (df['candle_10perc_100'] < 0.5) & # # Check if the high price of the current candle is not 3% or more above the open price # (df['current_candle_perc_change'] < 0.75) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'WT transition - bull') df.loc[ ( (df['close'] > df[f'zema_{self.filterlength.value}'])& (df['close'] < df['s1']) & (df['200_SMA'] > df['200_SMA'].shift(1)) & (df[f'wave_t1{self.wavelength.value}'] > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # Guard: Wave 1 is raising (df[f'wave_t1{self.wavelength.value}'] < self.buy_wt_bull.value) & (df[f'wave_t1{self.wavelength.value}'].shift(2) > df[f'wave_t1{self.wavelength.value}'].shift(1)) & # Check if no candle high price rose more than 5% in the past 50 candles (df['candle_3perc_100'] == 0) & # Check if the price has not gone up 10% or more over the last hundred candles (df['candle_10perc_100'] < 0.5) & # Check if the high price of the current candle is not 3% or more above the open price (df['current_candle_perc_change'] < 0.75) & (df['volume'] > 0) # Make sure Volume is not 0 ), ['enter_long', 'enter_tag']] = (1, 'WT - bull') # df.loc[ # ( # (df['close'] > df[f'zema_{self.filterlength.value}'])& # (df['rsi'] > self.buy_rsi.value) & # (df['rsi'] < self.buy_rsi_bear.value) & # (df['200_SMA'] < df['200_SMA'].shift(1)) & # (qtpylib.crossed_above(df['rsi'], df['rsi_ma'])) & # # Check if no candle high price rose more than 5% in the past 50 candles # (df['candle_3perc_100'] == 0) & # # Check if the price has not gone up 10% or more over the last hundred candles # (df['candle_10perc_100'] < 0.5) & # # Check if the high price of the current candle is not 3% or more above the open price # (df['current_candle_perc_change'] < 0.75) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'RSI-XO bear') # df.loc[ # ( # (df['rsi'] > self.buy_rsi.value) & # (df['rsi'] < self.buy_rsi_bull.value) & # (df['30_SMA'] > df['200_SMA']) & # (df['200_SMA'] > df['200_SMA'].shift(1)) & # (qtpylib.crossed_above(df['rsi'], df['rsi_ma'])) & # # Check if no candle high price rose more than 5% in the past 50 candles # (df['candle_3perc_100'] == 0) & # # Check if the price has not gone up 10% or more over the last hundred candles # (df['candle_10perc_100'] < 0.5) & # # Check if the high price of the current candle is not 3% or more above the open price # (df['current_candle_perc_change'] < 0.75) & # (df['volume'] > 0) # Make sure Volume is not 0 # ), # ['enter_long', 'enter_tag']] = (1, 'RSI-XO bull') return df ### EXIT CONDITIONS ### def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame: df.loc[ ( (qtpylib.crossed_below(df[f'zema_{self.filterlength.value}'], df['r3'])) & (df['volume'] > 0) # Make sure Volume is not 0 ), ['exit_long', 'exit_tag']] = (1, 'R3 - XO') df.loc[ ( (qtpylib.crossed_below(df[f'zema_{self.filterlength.value}'], df['r2.75'])) & (df['volume'] > 0) # Make sure Volume is not 0 ), ['exit_long', 'exit_tag']] = (1, 'R2.75 - XO') df.loc[ ( (qtpylib.crossed_below(df[f'zema_{self.filterlength.value}'], df['r2.50'])) & (df['volume'] > 0) # Make sure Volume is not 0 ), ['exit_long', 'exit_tag']] = (1, 'R2.5 - XO') df.loc[ ( (qtpylib.crossed_below(df[f'zema_{self.filterlength.value}'], df['r2.25'])) & (df['volume'] > 0) # Make sure Volume is not 0 ), ['exit_long', 'exit_tag']] = (1, 'R2.25 - XO') df.loc[ ( (qtpylib.crossed_below(df[f'zema_{self.filterlength.value}'], df['r2'])) & (df['volume'] > 0) # Make sure Volume is not 0 ), ['exit_long', 'exit_tag']] = (1, 'R2 - XO') return df |
Strategy League — fixed backtest that feeds the ranking
Export report Freqtrade logsRun finished · took 687.7s
ℹ️ This strategy uses a trailing stop / custom_stoploss() — freqtrade only
re-checks these once per 15m candle by default, not against the price movement within it.
For a more accurate read, re-run this backtest locally with --timeframe-detail 1m. Freqle doesn't do this for every check here: multiplying every
League/sweep backtest by a finer detail timeframe is more compute than the sandbox can sustain
across every indexed strategy. why this matters →
- profit isn't statistically significant (p=1.00) — hard to tell apart from luck
- only 0% of resampled runs were profitable
- profitable in only 21% of rolling 3-month windows
- did not beat simply holding the market
- very deep drawdown (-91%)
Resampling the trade sequence 2,000× shows the spread of results this edge could plausibly produce — separating a dependable strategy from one that got lucky once.
Loading charts…
Monthly breakdown
| Month | Regime | Trades | Profit % | Avg % | Win | Loss | Win % | DD % | Avg dur |
|---|---|---|---|---|---|---|---|---|---|
| Dec 2025 | bearish trending low vol | 6 | -2.20 | -3.67 | 3 | 3 | 50.0 | -90.8 | 57h 38m |
| Nov 2025 | bearish trending high vol | 11 | -2.69 | -2.46 | 7 | 4 | 63.6 | -89.07 | 26h 48m |
| Oct 2025 | bearish trending low vol | 10 | +0.17 | 0.18 | 9 | 1 | 90.0 | -86.08 | 49h 21m |
| Sep 2025 | bullish choppy low vol | 19 | +0.97 | 0.51 | 18 | 1 | 94.7 | -87.04 | 31h 51m |
| Aug 2025 | bullish choppy low vol | 6 | -1.48 | -2.46 | 4 | 2 | 66.7 | -87.21 | 110h 22m |
| Jul 2025 | bullish choppy low vol | 15 | +1.68 | 1.12 | 15 | 0 | 100.0 | -87.12 | 36h 21m |
| Jun 2025 | bearish choppy low vol | 19 | +0.11 | 0.05 | 16 | 3 | 84.2 | -88.32 | 37h 02m |
| May 2025 | bullish trending low vol | 10 | +0.24 | 0.24 | 9 | 1 | 90.0 | -88.11 | 54h 40m |
| Apr 2025 | bullish choppy low vol | 13 | +0.24 | 0.18 | 12 | 1 | 92.3 | -88.81 | 29h 06m |
| Mar 2025 | bearish trending high vol | 20 | +1.05 | 0.53 | 19 | 1 | 95.0 | -89.35 | 23h 55m |
| Feb 2025 | bearish trending low vol | 9 | -0.50 | -0.56 | 7 | 2 | 77.8 | -89.19 | 43h 08m |
| Jan 2025 | bearish choppy low vol | 17 | -2.38 | -1.40 | 12 | 5 | 70.6 | -88.55 | 25h 22m |
| Dec 2024 | bullish trending low vol | 15 | -1.86 | -1.24 | 11 | 4 | 73.3 | -86.28 | 19h 16m |
| Nov 2024 | bullish trending low vol | 19 | -0.56 | -0.30 | 15 | 4 | 78.9 | -85.26 | 21h 20m |
| Oct 2024 | bullish choppy low vol | 17 | -0.53 | -0.31 | 15 | 2 | 88.2 | -84.69 | 79h 30m |
| Aug 2024 | bearish choppy high vol | 15 | -1.50 | -1.00 | 12 | 3 | 80.0 | -83.35 | 29h 31m |
| Jul 2024 | bearish trending low vol | 22 | -1.39 | -0.63 | 18 | 4 | 81.8 | -83.15 | 32h 55m |
| Jun 2024 | bearish choppy low vol | 14 | -3.50 | -2.50 | 9 | 5 | 64.3 | -80.61 | 81h 56m |
| May 2024 | bullish choppy high vol | 35 | -2.79 | -0.80 | 28 | 7 | 80.0 | -77.19 | 26h 58m |
| Apr 2024 | bearish choppy high vol | 33 | -2.08 | -0.63 | 26 | 7 | 78.8 | -76.58 | 20h 45m |
| Mar 2024 | bullish trending high vol | 38 | +0.83 | 0.22 | 33 | 5 | 86.8 | -75.42 | 24h 12m |
| Feb 2024 | bullish trending low vol | 37 | +0.82 | 0.22 | 33 | 4 | 89.2 | -74.08 | 30h 09m |
| Jan 2024 | bearish choppy high vol | 37 | -2.72 | -0.74 | 30 | 7 | 81.1 | -74.08 | 26h 13m |
| Dec 2023 | bullish trending low vol | 44 | +0.49 | 0.11 | 38 | 6 | 86.4 | -72.11 | 27h 19m |
| Nov 2023 | bullish trending low vol | 39 | +0.79 | 0.20 | 33 | 6 | 84.6 | -72.41 | 25h 28m |
| Oct 2023 | bullish trending low vol | 38 | +1.01 | 0.27 | 35 | 3 | 92.1 | -74.67 | 28h 36m |
| Sep 2023 | bearish choppy low vol | 33 | +0.84 | 0.26 | 31 | 2 | 93.9 | -75.84 | 34h 57m |
| Aug 2023 | bearish choppy low vol | 15 | -1.70 | -1.13 | 12 | 3 | 80.0 | -75.21 | 107h 09m |
| Jul 2023 | bullish trending low vol | 18 | +1.31 | 0.73 | 16 | 2 | 88.9 | -74.1 | 47h 02m |
| Jun 2023 | bullish trending low vol | 28 | -7.54 | -2.69 | 17 | 11 | 60.7 | -74.25 | 71h 57m |
| May 2023 | bearish choppy low vol | 24 | -3.78 | -1.57 | 18 | 6 | 75.0 | -66.85 | 45h 58m |
| Apr 2023 | bullish trending low vol | 28 | -0.68 | -0.24 | 23 | 5 | 82.1 | -64.36 | 68h 28m |
| Mar 2023 | bullish trending high vol | 32 | +1.60 | 0.50 | 29 | 3 | 90.6 | -66.12 | 41h 08m |
| Feb 2023 | bullish trending low vol | 40 | -3.55 | -0.89 | 31 | 9 | 77.5 | -64.12 | 42h 52m |
| Jan 2023 | bullish trending low vol | 44 | +6.60 | 1.50 | 44 | 0 | 100.0 | -66.96 | 45h 03m |
| Dec 2022 | bearish trending low vol | 23 | -5.59 | -2.43 | 15 | 8 | 65.2 | -67.1 | 58h 39m |
| Nov 2022 | bearish trending high vol | 34 | -2.59 | -0.76 | 27 | 7 | 79.4 | -62.27 | 33h 17m |
| Oct 2022 | bullish choppy low vol | 44 | -1.17 | -0.27 | 38 | 6 | 86.4 | -62.43 | 56h 53m |
| Sep 2022 | bearish choppy high vol | 50 | -0.56 | -0.11 | 42 | 8 | 84.0 | -59.38 | 22h 24m |
| Aug 2022 | bullish choppy high vol | 49 | -4.57 | -0.93 | 36 | 13 | 73.5 | -57.77 | 24h 26m |
| Jul 2022 | bearish trending high vol | 61 | +1.31 | 0.21 | 51 | 10 | 83.6 | -54.5 | 21h 08m |
| Jun 2022 | bearish trending high vol | 31 | -3.40 | -1.10 | 22 | 9 | 71.0 | -55.41 | 24h 18m |
| May 2022 | bearish trending high vol | 27 | +0.61 | 0.23 | 23 | 4 | 85.2 | -54.02 | 17h 22m |
| Apr 2022 | bearish choppy high vol | 52 | -8.74 | -1.68 | 36 | 16 | 69.2 | -51.66 | 24h 15m |
| Mar 2022 | bullish choppy high vol | 64 | -0.14 | -0.02 | 55 | 9 | 85.9 | -48.09 | 24h 53m |
| Feb 2022 | bearish trending high vol | 59 | -3.85 | -0.65 | 44 | 15 | 74.6 | -44.75 | 21h 04m |
| Jan 2022 | bearish trending high vol | 40 | -7.03 | -1.76 | 28 | 12 | 70.0 | -39.7 | 34h 04m |
| Dec 2021 | bearish trending high vol | 58 | -6.63 | -1.14 | 43 | 15 | 74.1 | -34.21 | 22h 00m |
| Nov 2021 | bullish trending high vol | 77 | -0.41 | -0.05 | 64 | 13 | 83.1 | -27.99 | 29h 31m |
| Oct 2021 | bullish trending high vol | 87 | -5.48 | -0.63 | 68 | 19 | 78.2 | -26.1 | 26h 48m |
| Sep 2021 | bearish trending high vol | 68 | -10.53 | -1.55 | 47 | 21 | 69.1 | -21.18 | 30h 53m |
| Aug 2021 | bullish trending high vol | 90 | +6.87 | 0.76 | 80 | 10 | 88.9 | -18.3 | 16h 27m |
| Jul 2021 | bearish trending high vol | 75 | -8.16 | -1.09 | 52 | 23 | 69.3 | -24.86 | 27h 18m |
| Jun 2021 | bearish trending high vol | 36 | -3.38 | -0.94 | 24 | 12 | 66.7 | -11.87 | 17h 54m |
| May 2021 | bearish trending high vol | 22 | -5.80 | -2.64 | 13 | 9 | 59.1 | -5.95 | 16h 12m |
| Apr 2021 | bearish choppy high vol | 55 | +7.38 | 1.34 | 52 | 3 | 94.5 | -5.18 | 12h 52m |
| Mar 2021 | bullish choppy high vol | 84 | -2.88 | -0.34 | 67 | 17 | 79.8 | -7.23 | 22h 10m |
| Feb 2021 | bullish trending high vol | 34 | +1.80 | 0.53 | 29 | 5 | 85.3 | -3.73 | 22h 52m |
| Jan 2021 | bullish trending high vol | 25 | -2.81 | -1.12 | 18 | 7 | 72.0 | -4.32 | 15h 10m |
Yearly breakdown
| Year | Trades | Profit % | Avg % | Win | Loss | Win % | DD % | Avg dur |
|---|---|---|---|---|---|---|---|---|
| 2025 | 155 | -4.79 | -0.31 | 131 | 24 | 84.5 | -90.8 | 37h 53m |
| 2024 | 282 | -15.28 | -0.54 | 230 | 52 | 81.6 | -86.28 | 31h 54m |
| 2023 | 383 | -4.61 | -0.12 | 327 | 56 | 85.4 | -75.84 | 44h 13m |
| 2022 | 534 | -35.72 | -0.67 | 417 | 117 | 78.1 | -67.1 | 28h 36m |
| 2021 | 711 | -30.03 | -0.42 | 557 | 154 | 78.3 | -34.21 | 22h 50m |
Trade charts — best 2 and worst 2 performing pairs (full OHLC candles are expensive to render for every pair)
Backtests — over a market period
Backtest this strategy over a chosen crypto-cycle period. These don't affect the League ranking, and need that period's candle data downloaded.
Log in or sign up to run backtests.
| Period | Range | Total % | Win % | Max DD | Trades | |
|---|---|---|---|---|---|---|
| 2020 · DeFi Summer & Pre-Halving Rally | 20200101-20210101 | not run | ||||
| 2021 · Institutional Bull Market | 20210101-20220101 | not run | ||||
| 2022 · Post-Bull Crash & Macro Tightening | 20220101-20230101 | not run | ||||
| 2023–2024 · Recovery & ETF Anticipation | 20230101-20250101 | not run | ||||
| 2025–2026 · Current Cycle | 20250101-20260101 | not run | ||||
Walk forward
Out-of-sample backtest on recent data · 33 pairs · 20260101-20260701.
Backtest trust check
1 potential lookahead pattern(s) found · 3 to review
| Line | Pattern | Detail | |
|---|---|---|---|
| 251 | review | repaint_indicator | 'pivots_points' repaints -- a pivot is only identifiable once later bars have printed. Fine if you shift the result forward by `order`, or if it builds ML training labels; a leak if the raw value is traded at the bar it marks. |
| 318 | leak | whole_series_reduction | .max() over the whole column sees future rows (use .rolling(window).max() for a causal value) |
| 31 | review | startup_candles_too_small | startup_candle_count is 30, but SMA(timeperiod=200) needs at least 200 candles -- so the first 170+ candles of every backtest use an indicator that hasn't warmed up. Recursive indicators (EMA/RSI/ADX/ATR) want several times their period, not exactly it |
| 475 | review | enter_tag_overwrite | enter_tag/exit_tag is written by 6 separate assignments -- they share one column and run in source order, so a row matching more than one condition keeps only the LAST tag. Per-tag statistics won't mean what they appear to |
ran by Ron · took s
Lookahead analysis
freqtrade lookahead-analysis: detects strategies peeking at future candles.