15 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 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement # flake8: noqa: F401 # isort: skip_file # --- Do not remove these imports --- import numpy as np import pandas as pd import math from datetime import datetime, timedelta, timezone from pandas import DataFrame from typing import Optional, Union from collections import deque from freqtrade.strategy import ( IStrategy, Trade, Order, PairLocks, informative, BooleanParameter, CategoricalParameter, DecimalParameter, IntParameter, RealParameter, timeframe_to_minutes, timeframe_to_next_date, timeframe_to_prev_date, merge_informative_pair, stoploss_from_absolute, stoploss_from_open, ) import talib.abstract as ta from technical import qtpylib class TrendBreakoutStrategyV2(IStrategy): """ 趋势突破策略V2 - 优化版 主要改进: 1. 使用Supertrend代替EMA系统,减少假信号 2. 加入VWAP作为趋势确认 3. 实施三重确认系统(趋势+动量+结构) 4. 优化入场评分系统,提高门槛 5. 动态止损和分批建仓 目标: - 胜率提升至35-45% - 盈亏比1.5-2.0 - 最大回撤控制在10%以内 """ INTERFACE_VERSION = 3 can_short: bool = False # 基础参数设置 minimal_roi = {"0": 10} stoploss = -0.05 # 5%兜底止损(提高容错) trailing_stop = False timeframe = '15m' use_custom_stoploss = True use_exit_signal = True exit_profit_only = False ignore_roi_if_entry_signal = False # === 核心策略参数(简化版)=== # Supertrend参数(主要趋势信号) st_atr_period = IntParameter(12, 18, default=14, space="buy", optimize=True) st_multiplier = DecimalParameter(2.0, 3.0, default=2.5, space="buy", optimize=True) # MACD参数(动量确认) macd_fast = IntParameter(10, 14, default=12, space="buy", optimize=True) macd_slow = IntParameter(24, 28, default=26, space="buy", optimize=True) macd_signal = IntParameter(8, 10, default=9, space="buy", optimize=True) # RSI参数(超买超卖) rsi_period = IntParameter(12, 16, default=14, space="buy", optimize=True) rsi_overbought = IntParameter(68, 75, default=70, space="buy", optimize=True) # ADX参数(趋势强度 - 市场过滤器) adx_period = IntParameter(12, 16, default=14, space="buy", optimize=True) adx_threshold = IntParameter(25, 35, default=28, space="buy", optimize=True) # 成交量确认(简化) volume_multiplier = DecimalParameter(1.3, 2.0, default=1.5, space="buy", optimize=True) # === 风险管理参数(简化版)=== # 简化止损系统 - 基于ATR atr_stop_multiplier = DecimalParameter(2.0, 3.5, default=2.5, space="sell", optimize=True) # 三级止盈系统(来自成功策略) profit_threshold_1 = DecimalParameter(0.02, 0.04, default=0.03, space="sell", optimize=True) # 3% profit_threshold_2 = DecimalParameter(0.06, 0.10, default=0.08, space="sell", optimize=True) # 8% profit_threshold_3 = DecimalParameter(0.15, 0.25, default=0.20, space="sell", optimize=True) # 20% startup_candle_count: int = 200 def __init__(self, config: dict): super().__init__(config) self.custom_info = {} # 简化的交易信息存储 def calculate_supertrend(self, dataframe: DataFrame, period: int = 14, multiplier: float = 2.5) -> tuple: """计算Supertrend指标""" high = dataframe['high'] low = dataframe['low'] close = dataframe['close'] # 计算ATR atr = ta.ATR(dataframe, timeperiod=period) # 计算基础线 hl_avg = (high + low) / 2 # 计算上下轨 upper_band = hl_avg + (multiplier * atr) lower_band = hl_avg - (multiplier * atr) # 初始化 supertrend = pd.Series(index=dataframe.index, dtype=float) direction = pd.Series(index=dataframe.index, dtype=float) for i in range(period, len(dataframe)): # 上轨调整 if upper_band.iloc[i] < upper_band.iloc[i-1] or close.iloc[i-1] > upper_band.iloc[i-1]: upper_band.iloc[i] = upper_band.iloc[i] else: upper_band.iloc[i] = upper_band.iloc[i-1] # 下轨调整 if lower_band.iloc[i] > lower_band.iloc[i-1] or close.iloc[i-1] < lower_band.iloc[i-1]: lower_band.iloc[i] = lower_band.iloc[i] else: lower_band.iloc[i] = lower_band.iloc[i-1] # 确定趋势方向 if i == period: if close.iloc[i] <= upper_band.iloc[i]: direction.iloc[i] = -1 else: direction.iloc[i] = 1 else: if direction.iloc[i-1] == -1: if close.iloc[i] <= upper_band.iloc[i]: direction.iloc[i] = -1 else: direction.iloc[i] = 1 else: if close.iloc[i] >= lower_band.iloc[i]: direction.iloc[i] = 1 else: direction.iloc[i] = -1 # 设置Supertrend值 if direction.iloc[i] == 1: supertrend.iloc[i] = lower_band.iloc[i] else: supertrend.iloc[i] = upper_band.iloc[i] return supertrend, direction def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: """计算所需的技术指标""" # === Supertrend指标 === dataframe['supertrend'], dataframe['st_direction'] = self.calculate_supertrend( dataframe, period=self.st_atr_period.value, multiplier=self.st_multiplier.value ) dataframe['st_uptrend'] = dataframe['st_direction'] == 1 # === MACD指标(动量确认)=== macd = ta.MACD(dataframe, fastperiod=self.macd_fast.value, slowperiod=self.macd_slow.value, signalperiod=self.macd_signal.value) dataframe['macd_hist'] = macd['macdhist'] dataframe['macd_bullish'] = (macd['macdhist'] > 0) & (macd['macdhist'] > macd['macdhist'].shift(1)) # === RSI指标(超买过滤)=== dataframe['rsi'] = ta.RSI(dataframe, timeperiod=self.rsi_period.value) dataframe['rsi_ok'] = dataframe['rsi'] < self.rsi_overbought.value # === ADX指标(趋势强度 - 市场过滤器)=== dataframe['adx'] = ta.ADX(dataframe, timeperiod=self.adx_period.value) dataframe['trending_market'] = dataframe['adx'] > self.adx_threshold.value # === 成交量确认(简化)=== dataframe['volume_ma20'] = dataframe['volume'].rolling(20).mean() dataframe['volume_surge'] = dataframe['volume'] > (dataframe['volume_ma20'] * self.volume_multiplier.value) # === ATR(用于动态止损)=== dataframe['atr'] = ta.ATR(dataframe, timeperiod=self.st_atr_period.value) # === 波动率计算(用于仓位管理)=== dataframe['price_change'] = dataframe['close'].pct_change() dataframe['volatility'] = dataframe['price_change'].rolling(20).std() * np.sqrt(24 * 60 / 15) # 15m to daily return dataframe def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: """定义入场条件""" # 多头入场条件 - 简化版本(4个核心信号确认) dataframe.loc[ ( # 1. 趋势确认:Supertrend 上升趋势 (dataframe['st_uptrend'] == True) & # 2. 动量确认:MACD 看涨 (dataframe['macd_bullish'] == True) & # 3. 市场过滤:只在强趋势市场交易 (dataframe['trending_market'] == True) & # 4. 成交量确认:成交量放大 (dataframe['volume_surge'] == True) & # 5. 风险过滤:RSI 未超买 (dataframe['rsi_ok'] == True) & # 基础有效性检查 (dataframe['volume'] > 0) ), 'enter_long' ] = 1 return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: """定义出场条件 - 简化版本""" # 趋势反转退出(简化条件) dataframe.loc[ ( # Supertrend 转向或 RSI 超买 (dataframe['st_uptrend'] == False) | (dataframe['rsi'] > 80) ), 'exit_long' ] = 1 return dataframe 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: """基于波动率的动态仓位管理""" # 获取最新数据 dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) if dataframe is None or len(dataframe) == 0: return proposed_stake * 0.02 # 2% 默认仓位 latest = dataframe.iloc[-1] current_volatility = latest.get('volatility', 0.02) # 默认波动率 2% # 获取账户余额 account_balance = self.wallets.get_total_stake_amount() # 基于波动率的仓位计算 - 波动率越高仓位越小 base_risk = 0.02 # 2% 基础风险 volatility_factor = min(current_volatility / 0.02, 3.0) if current_volatility > 0 else 1.0 # 最大 3倍波动率调整 adjusted_risk = base_risk / max(volatility_factor, 1.0) position_size = account_balance * adjusted_risk # 应用最小/最大限制 if min_stake: position_size = max(position_size, min_stake) position_size = min(position_size, max_stake) return position_size def custom_stoploss(self, pair: str, trade: Trade, current_time: datetime, current_rate: float, current_profit: float, **kwargs) -> float: """简化的3级止损系统(来自成功策略)""" # 获取最新数据 dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) if dataframe is None or len(dataframe) == 0: return self.stoploss latest = dataframe.iloc[-1] atr = latest.get('atr', 0.01) # 初始止损基于ATR initial_stop = -self.atr_stop_multiplier.value * atr / current_rate # 3级盈利保护系统 if current_profit > self.profit_threshold_3.value: # >20% 利润 return current_profit - 0.08 # 保护 8% 利润 elif current_profit > self.profit_threshold_2.value: # >8% 利润 return current_profit - 0.04 # 保护 4% 利润 elif current_profit > self.profit_threshold_1.value: # >3% 利润 return current_profit - 0.02 # 保护 2% 利润 else: return initial_stop def custom_exit(self, pair: str, trade: Trade, current_time: datetime, current_rate: float, current_profit: float, **kwargs) -> Union[str, None]: """简化的自定义出场逻辑""" # 获取最新数据 dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) if dataframe is None or len(dataframe) == 0: return None latest = dataframe.iloc[-1] # RSI极度超买退出 if latest['rsi'] > 80: return "rsi_extreme_overbought" # Supertrend趋势反转 if not latest['st_uptrend']: return "trend_reversal" return None |
Strategy League — fixed backtest that feeds the ranking
Export report Freqtrade logsRun finished · took 856.1s
ℹ️ This strategy uses 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 0% of rolling 3-month windows
- did not beat simply holding the market
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 | 582 | -1.28 | -0.33 | 95 | 487 | 16.3 | -50.63 | 0h 14m |
| Nov 2025 | bearish trending high vol | 355 | -0.57 | -0.26 | 84 | 271 | 23.7 | -49.35 | 0h 14m |
| Oct 2025 | bearish trending low vol | 514 | -0.62 | -0.18 | 143 | 371 | 27.8 | -48.78 | 0h 14m |
| Sep 2025 | bullish choppy low vol | 434 | -0.65 | -0.20 | 106 | 328 | 24.4 | -48.17 | 0h 14m |
| Aug 2025 | bullish choppy low vol | 509 | -0.74 | -0.24 | 139 | 370 | 27.3 | -47.51 | 0h 15m |
| Jul 2025 | bullish choppy low vol | 426 | -0.66 | -0.24 | 106 | 320 | 24.9 | -46.77 | 0h 14m |
| Jun 2025 | bearish choppy low vol | 478 | -0.91 | -0.29 | 100 | 378 | 20.9 | -46.11 | 0h 15m |
| May 2025 | bullish trending low vol | 423 | -0.57 | -0.21 | 130 | 293 | 30.7 | -45.21 | 0h 15m |
| Apr 2025 | bullish choppy low vol | 465 | -0.84 | -0.29 | 123 | 342 | 26.5 | -44.64 | 0h 14m |
| Mar 2025 | bearish trending high vol | 488 | -0.81 | -0.26 | 143 | 345 | 29.3 | -43.8 | 0h 14m |
| Feb 2025 | bearish trending low vol | 318 | -0.47 | -0.23 | 96 | 222 | 30.2 | -42.99 | 0h 14m |
| Jan 2025 | bearish choppy low vol | 495 | -0.61 | -0.19 | 170 | 325 | 34.3 | -42.53 | 0h 15m |
| Dec 2024 | bullish trending low vol | 450 | -0.66 | -0.25 | 136 | 314 | 30.2 | -41.92 | 0h 15m |
| Nov 2024 | bullish trending low vol | 419 | -0.66 | -0.25 | 133 | 286 | 31.7 | -41.25 | 0h 14m |
| Oct 2024 | bullish choppy low vol | 481 | -0.98 | -0.26 | 113 | 368 | 23.5 | -40.59 | 0h 15m |
| Sep 2024 | bearish choppy low vol | 472 | -0.78 | -0.19 | 113 | 359 | 23.9 | -39.61 | 0h 15m |
| Aug 2024 | bearish choppy high vol | 510 | -0.89 | -0.24 | 139 | 371 | 27.3 | -38.83 | 0h 14m |
| Jul 2024 | bearish trending low vol | 459 | -0.77 | -0.22 | 110 | 349 | 24.0 | -37.95 | 0h 14m |
| Jun 2024 | bearish choppy low vol | 592 | -1.15 | -0.23 | 122 | 470 | 20.6 | -37.17 | 0h 15m |
| May 2024 | bullish choppy high vol | 442 | -0.96 | -0.27 | 91 | 351 | 20.6 | -36.02 | 0h 14m |
| Apr 2024 | bearish choppy high vol | 391 | -0.64 | -0.23 | 118 | 273 | 30.2 | -35.06 | 0h 15m |
| Mar 2024 | bullish trending high vol | 373 | -0.56 | -0.22 | 124 | 249 | 33.2 | -34.42 | 0h 14m |
| Feb 2024 | bullish trending low vol | 389 | -0.77 | -0.25 | 104 | 285 | 26.7 | -33.86 | 0h 14m |
| Jan 2024 | bearish choppy high vol | 494 | -1.21 | -0.37 | 136 | 358 | 27.5 | -33.09 | 0h 14m |
| Dec 2023 | bullish trending low vol | 452 | -0.78 | -0.23 | 144 | 308 | 31.9 | -31.88 | 0h 14m |
| Nov 2023 | bullish trending low vol | 358 | -0.61 | -0.22 | 107 | 251 | 29.9 | -31.11 | 0h 14m |
| Oct 2023 | bullish trending low vol | 506 | -1.27 | -0.24 | 73 | 433 | 14.4 | -30.49 | 0h 15m |
| Sep 2023 | bearish choppy low vol | 444 | -1.20 | -0.25 | 71 | 373 | 16.0 | -29.22 | 0h 14m |
| Aug 2023 | bearish choppy low vol | 465 | -1.35 | -0.27 | 66 | 399 | 14.2 | -28.02 | 0h 14m |
| Jul 2023 | bullish trending low vol | 363 | -0.87 | -0.26 | 81 | 282 | 22.3 | -26.66 | 0h 14m |
| Jun 2023 | bullish trending low vol | 409 | -0.96 | -0.25 | 86 | 323 | 21.0 | -25.79 | 0h 14m |
| May 2023 | bearish choppy low vol | 416 | -1.19 | -0.25 | 64 | 352 | 15.4 | -24.83 | 0h 14m |
| Apr 2023 | bullish trending low vol | 382 | -0.84 | -0.21 | 93 | 289 | 24.3 | -23.65 | 0h 14m |
| Mar 2023 | bullish trending high vol | 451 | -0.81 | -0.21 | 121 | 330 | 26.8 | -22.8 | 0h 14m |
| Feb 2023 | bullish trending low vol | 388 | -0.95 | -0.29 | 102 | 286 | 26.3 | -21.99 | 0h 14m |
| Jan 2023 | bullish trending low vol | 541 | -1.24 | -0.26 | 125 | 416 | 23.1 | -21.04 | 0h 14m |
| Dec 2022 | bearish trending low vol | 600 | -1.76 | -0.24 | 103 | 497 | 17.2 | -19.81 | 0h 14m |
| Nov 2022 | bearish trending high vol | 537 | -1.28 | -0.28 | 146 | 391 | 27.2 | -18.05 | 0h 14m |
| Oct 2022 | bullish choppy low vol | 511 | -1.32 | -0.25 | 113 | 398 | 22.1 | -16.77 | 0h 15m |
| Sep 2022 | bearish choppy high vol | 407 | -0.75 | -0.22 | 126 | 281 | 31.0 | -15.44 | 0h 14m |
| Aug 2022 | bullish choppy high vol | 432 | -0.88 | -0.26 | 125 | 307 | 28.9 | -14.7 | 0h 15m |
| Jul 2022 | bearish trending high vol | 464 | -1.00 | -0.28 | 128 | 336 | 27.6 | -13.82 | 0h 14m |
| Jun 2022 | bearish trending high vol | 377 | -0.71 | -0.28 | 121 | 256 | 32.1 | -12.82 | 0h 14m |
| May 2022 | bearish trending high vol | 320 | -0.54 | -0.24 | 112 | 208 | 35.0 | -12.1 | 0h 15m |
| Apr 2022 | bearish choppy high vol | 398 | -0.90 | -0.25 | 117 | 281 | 29.4 | -11.56 | 0h 14m |
| Mar 2022 | bullish choppy high vol | 291 | -0.66 | -0.26 | 76 | 215 | 26.1 | -10.67 | 0h 14m |
| Feb 2022 | bearish trending high vol | 346 | -0.63 | -0.26 | 107 | 239 | 30.9 | -10.01 | 0h 14m |
| Jan 2022 | bearish trending high vol | 381 | -0.88 | -0.30 | 97 | 284 | 25.5 | -9.39 | 0h 15m |
| Dec 2021 | bearish trending high vol | 386 | -0.86 | -0.28 | 112 | 274 | 29.0 | -8.49 | 0h 15m |
| Nov 2021 | bullish trending high vol | 309 | -0.55 | -0.21 | 94 | 215 | 30.4 | -7.63 | 0h 15m |
| Oct 2021 | bullish trending high vol | 318 | -0.72 | -0.29 | 91 | 227 | 28.6 | -7.1 | 0h 15m |
| Sep 2021 | bearish trending high vol | 267 | -0.74 | -0.39 | 69 | 198 | 25.8 | -6.37 | 0h 14m |
| Aug 2021 | bullish trending high vol | 286 | -0.46 | -0.23 | 93 | 193 | 32.5 | -5.62 | 0h 15m |
| Jul 2021 | bearish trending high vol | 296 | -0.54 | -0.22 | 102 | 194 | 34.5 | -5.16 | 0h 15m |
| Jun 2021 | bearish trending high vol | 307 | -0.68 | -0.30 | 94 | 213 | 30.6 | -4.62 | 0h 14m |
| May 2021 | bearish trending high vol | 291 | -0.57 | -0.31 | 117 | 174 | 40.2 | -3.94 | 0h 14m |
| Apr 2021 | bearish choppy high vol | 296 | -0.79 | -0.38 | 103 | 193 | 34.8 | -3.37 | 0h 14m |
| Mar 2021 | bullish choppy high vol | 367 | -0.78 | -0.28 | 112 | 255 | 30.5 | -2.59 | 0h 14m |
| Feb 2021 | bullish trending high vol | 280 | -0.96 | -0.53 | 80 | 200 | 28.6 | -1.8 | 0h 14m |
| Jan 2021 | bullish trending high vol | 333 | -0.83 | -0.36 | 117 | 216 | 35.1 | -0.84 | 0h 14m |
Yearly breakdown
| Year | Trades | Profit % | Avg % | Win | Loss | Win % | DD % | Avg dur |
|---|---|---|---|---|---|---|---|---|
| 2025 | 5487 | -8.73 | -0.25 | 1435 | 4052 | 26.2 | -50.63 | 0h 14m |
| 2024 | 5472 | -10.03 | -0.25 | 1439 | 4033 | 26.3 | -41.92 | 0h 14m |
| 2023 | 5175 | -12.07 | -0.25 | 1133 | 4042 | 21.9 | -31.88 | 0h 14m |
| 2022 | 5064 | -11.31 | -0.26 | 1371 | 3693 | 27.1 | -19.81 | 0h 14m |
| 2021 | 3736 | -8.48 | -0.31 | 1184 | 2552 | 31.7 | -8.49 | 0h 14m |
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
no lookahead-bias patterns detected
ran by Ron · took s
Lookahead analysis
freqtrade lookahead-analysis: detects strategies peeking at future candles.