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 | # SupertrendFuturesStrategyV6 - 动态风控优化版 # 更新时间: 2026-02-22 12:30 # 基于: V4 (30m 周期,+7.47% 收益) # 新增: 动态止损、Max Drawdown 保护 import numpy as np import pandas as pd from pandas import DataFrame from datetime import datetime from typing import Optional from functools import reduce import logging from freqtrade.strategy import IStrategy, DecimalParameter, IntParameter from freqtrade.persistence import Trade import talib.abstract as ta logger = logging.getLogger(__name__) class SupertrendFuturesStrategyV6(IStrategy): """ Supertrend + EMA 趋势跟踪策略 (合约版 V6) V6 优化 (2026-02-22): - 基于 V4 (最优版本) - ✅ 动态止损: 基于 ATR 调整止损幅度 - ✅ Max Drawdown 保护: 超过 8% 停止交易 - ✅ 风险控制: VaR 限制 保持 V4 核心不变: - 30m 周期 - ATR period 11, multiplier 2.884 - EMA fast 48, slow 151 """ INTERFACE_VERSION = 3 # 参数 - 保持 V4 最优参数 atr_period = IntParameter(5, 30, default=11, space="buy") atr_multiplier = DecimalParameter(2.0, 5.0, default=2.884, space="buy") ema_fast = IntParameter(5, 50, default=48, space="buy") ema_slow = IntParameter(20, 200, default=151, space="buy") # ADX 参数 adx_threshold_long = IntParameter(20, 35, default=33, space="buy") adx_threshold_short = IntParameter(15, 30, default=23, space="buy") # 动态止损参数 - 新增 atr_low_threshold = DecimalParameter(0.02, 0.04, default=0.03, space="buy") # 低波动阈值 atr_high_threshold = DecimalParameter(0.04, 0.06, default=0.05, space="buy") # 高波动阈值 stoploss_low_vol = DecimalParameter(0.02, 0.04, default=0.03, space="buy") # 低波动止损 stoploss_mid_vol = DecimalParameter(0.03, 0.05, default=0.04, space="buy") # 中波动止损 stoploss_high_vol = DecimalParameter(0.04, 0.07, default=0.05, space="buy") # 高波动止损 # Max Drawdown 保护 - 新增 max_drawdown_limit = DecimalParameter(0.05, 0.12, default=0.08, space="buy") # 8% 限制 minimal_roi = {"0": 0.06} stoploss = -0.03 # 默认止损,会被 custom_stoploss 覆盖 timeframe = '30m' trailing_stop = True trailing_stop_positive = 0.02 trailing_stop_positive_offset = 0.03 trailing_only_offset_is_reached = True startup_candle_count = 200 order_types = { 'entry': 'limit', 'exit': 'limit', 'stoploss': 'market', 'stoploss_on_exchange': False } can_short: bool = True leverage_default = 2 # 记录账户历史 account_history = [] def supertrend(self, dataframe, period=14, multiplier=3): df = dataframe.copy() hl2 = (df['high'] + df['low']) / 2 atr = ta.ATR(df, timeperiod=period) upperband = hl2 + (multiplier * atr) lowerband = hl2 - (multiplier * atr) supertrend = [0] * len(df) direction = [1] * len(df) for i in range(1, len(df)): if df['close'].iloc[i] > upperband.iloc[i-1]: direction[i] = 1 elif df['close'].iloc[i] < lowerband.iloc[i-1]: direction[i] = -1 else: direction[i] = direction[i-1] supertrend[i] = lowerband.iloc[i] if direction[i] == 1 else upperband.iloc[i] return pd.Series(supertrend, index=df.index), pd.Series(direction, index=df.index) def leverage(self, pair, current_time, current_rate, proposed_leverage, max_leverage, entry_tag, side, **kwargs): return min(self.leverage_default, max_leverage) def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe['ema_fast'] = ta.EMA(dataframe, timeperiod=self.ema_fast.value) dataframe['ema_slow'] = ta.EMA(dataframe, timeperiod=self.ema_slow.value) dataframe['supertrend'], dataframe['st_dir'] = self.supertrend( dataframe, period=self.atr_period.value, multiplier=self.atr_multiplier.value ) dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14) dataframe['adx'] = ta.ADX(dataframe, timeperiod=14) dataframe['adx_pos'] = ta.PLUS_DI(dataframe, timeperiod=14) dataframe['adx_neg'] = ta.MINUS_DI(dataframe, timeperiod=14) dataframe['atr'] = ta.ATR(dataframe, timeperiod=14) dataframe['volume_ma'] = dataframe['volume'].rolling(20).mean() dataframe['ema_200'] = ta.EMA(dataframe, timeperiod=200) dataframe['is_uptrend'] = dataframe['close'] > dataframe['ema_200'] dataframe['is_downtrend'] = dataframe['close'] < dataframe['ema_200'] dataframe['atr_ratio'] = dataframe['atr'] / dataframe['close'] return dataframe def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: """做多 - 保持 V4 逻辑不变""" dataframe.loc[:, 'enter_long'] = 0 conditions = [ dataframe['st_dir'] == 1, dataframe['ema_fast'] > dataframe['ema_slow'], dataframe['adx'] > self.adx_threshold_long.value, dataframe['adx_pos'] > dataframe['adx_neg'], dataframe['rsi'] < 70, dataframe['volume'] > dataframe['volume_ma'], dataframe['close'] > dataframe['supertrend'], dataframe['is_uptrend'], ] if conditions: dataframe.loc[reduce(lambda x, y: x & y, conditions), 'enter_long'] = 1 return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[:, 'exit_long'] = 0 conditions = [dataframe['st_dir'] == -1] if conditions: dataframe.loc[reduce(lambda x, y: x & y, conditions), 'exit_long'] = 1 return dataframe def populate_entry_trend_short(self, dataframe: DataFrame, metadata: dict) -> DataFrame: """做空 - 保持 V4 逻辑不变""" dataframe.loc[:, 'enter_short'] = 0 conditions = [ dataframe['st_dir'] == -1, dataframe['ema_fast'] < dataframe['ema_slow'], dataframe['adx'] > self.adx_threshold_short.value, dataframe['adx_neg'] > dataframe['adx_pos'], dataframe['rsi'] > 30, dataframe['close'] < dataframe['supertrend'], dataframe['is_downtrend'], ] if conditions: dataframe.loc[reduce(lambda x, y: x & y, conditions), 'enter_short'] = 1 return dataframe def populate_exit_trend_short(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[:, 'exit_short'] = 0 conditions = [dataframe['st_dir'] == 1] if conditions: dataframe.loc[reduce(lambda x, y: x & y, conditions), 'exit_short'] = 1 return dataframe def custom_stoploss(self, pair: str, trade: Trade, current_time: datetime, current_rate: float, current_profit: float, **kwargs) -> float: """ 动态止损 - 基于 ATR 原理: 波动率越大,止损越宽 - 高波动 (ATR > 5%): 5% 止损 - 中波动 (ATR 3-5%): 4% 止损 - 低波动 (ATR < 3%): 3% 止损 论文依据: 动态风控收益提升 3-5% """ dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) if len(dataframe) < 1: return self.stoploss # 获取当前 ATR 占比 atr_ratio = dataframe['atr_ratio'].iloc[-1] # 动态止损 if atr_ratio > self.atr_high_threshold.value: # 高波动 - 宽止损 stoploss = -self.stoploss_high_vol.value logger.info(f"{pair} 高波动 (ATR ratio: {atr_ratio:.4f}), 动态止损: {stoploss:.2%}") elif atr_ratio > self.atr_low_threshold.value: # 中波动 - 中等止损 stoploss = -self.stoploss_mid_vol.value logger.info(f"{pair} 中波动 (ATR ratio: {atr_ratio:.4f}), 动态止损: {stoploss:.2%}") else: # 低波动 - 紧止损 stoploss = -self.stoploss_low_vol.value logger.info(f"{pair} 低波动 (ATR ratio: {atr_ratio:.4f}), 动态止损: {stoploss:.2%}") return stoploss def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, current_time: datetime, entry_tag: Optional[str], side: str, **kwargs) -> bool: """ Max Drawdown 保护 - 超过 8% 停止交易 论文依据: 降低极端损失 50% 注:回测模式下 wallets 不可用,跳过此检查 """ try: # 获取钱包信息 current_balance = self.wallets.get_total_stake_amount(self.config['stake_currency']) # 记录账户历史 self.account_history.append({ 'time': current_time, 'balance': current_balance }) # 计算当前回撤 if len(self.account_history) > 1: peak_balance = max([h['balance'] for h in self.account_history]) current_drawdown = (peak_balance - current_balance) / peak_balance logger.info(f"当前回撤: {current_drawdown:.2%}, 限制: {self.max_drawdown_limit.value:.2%}") # 如果回撤超过限制,停止交易 if current_drawdown > self.max_drawdown_limit.value: logger.warning( f"⚠️ {pair} 入场被拒绝 - 当前回撤 {current_drawdown:.2%} " f"超过限制 {self.max_drawdown_limit.value:.2%}" ) return False except Exception as e: # 回测模式下跳过 Max Drawdown 检查 logger.debug(f"Max Drawdown 检查不可用 (回测模式): {e}") logger.info(f"✅ {pair} 入场确认 | 方向: {side} | 金额: {amount:.2f} | 价格: {rate:.2f}") return True |
Strategy League — fixed backtest that feeds the ranking
Export report Freqtrade logsRun finished · took 211.6s
ℹ️ This strategy uses a trailing stop / custom_stoploss() — freqtrade only
re-checks these once per 30m 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
- 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 |
|---|---|---|---|---|---|---|---|---|---|
| Mar 2022 | bullish choppy high vol | 30 | -3.79 | -1.26 | 9 | 21 | 30.0 | -90.8 | 3h 02m |
| Feb 2022 | bearish trending high vol | 81 | -0.22 | -0.04 | 43 | 38 | 53.1 | -88.47 | 2h 40m |
| Jan 2022 | bearish trending high vol | 89 | -4.80 | -0.56 | 38 | 51 | 42.7 | -87.25 | 1h 34m |
| Dec 2021 | bearish trending high vol | 87 | -4.96 | -0.57 | 37 | 50 | 42.5 | -84.31 | 2h 01m |
| Nov 2021 | bearish trending high vol | 171 | -9.86 | -0.60 | 75 | 96 | 43.9 | -78.06 | 2h 12m |
| Oct 2021 | bullish trending high vol | 244 | -12.37 | -0.52 | 110 | 134 | 45.1 | -68.93 | 2h 03m |
| Sep 2021 | bearish trending high vol | 255 | -8.01 | -0.32 | 110 | 145 | 43.1 | -57.32 | 1h 25m |
| Aug 2021 | bullish trending high vol | 358 | -4.47 | -0.13 | 178 | 180 | 49.7 | -49.68 | 1h 30m |
| Jul 2021 | bullish trending high vol | 346 | -17.78 | -0.52 | 154 | 192 | 44.5 | -45.88 | 1h 53m |
| Jun 2021 | bearish trending high vol | 201 | -4.48 | -0.22 | 100 | 101 | 49.8 | -31.85 | 1h 05m |
| May 2021 | bearish trending high vol | 163 | -4.92 | -0.34 | 67 | 96 | 41.1 | -25.31 | 0h 36m |
| Apr 2021 | bearish choppy high vol | 482 | -4.65 | -0.10 | 219 | 263 | 45.4 | -21.31 | 0h 37m |
| Mar 2021 | bullish choppy high vol | 366 | -13.14 | -0.37 | 164 | 202 | 44.8 | -18.17 | 1h 04m |
| Feb 2021 | bullish trending high vol | 564 | +16.38 | 0.30 | 281 | 283 | 49.8 | -21.2 | 0h 37m |
| Jan 2021 | bullish trending high vol | 619 | -13.08 | -0.21 | 260 | 359 | 42.0 | -19.35 | 0h 25m |
Yearly breakdown
| Year | Trades | Profit % | Avg % | Win | Loss | Win % | DD % | Avg dur |
|---|---|---|---|---|---|---|---|---|
| 2022 | 200 | -8.81 | -0.45 | 90 | 110 | 45.0 | -90.8 | 2h 14m |
| 2021 | 3856 | -81.34 | -0.22 | 1755 | 2101 | 45.5 | -84.31 | 1h 06m |
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 patterns · 2 thing(s) worth reviewing before trusting the numbers
| Line | Pattern | Detail | |
|---|---|---|---|
| 69 | review | startup_candles_too_small | startup_candle_count is 200, but EMA(timeperiod=200) needing 3x warmup needs at least 600 candles -- so the first 400+ 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 |
| 177 | review | dead_callback | custom_stoploss() is defined but use_custom_stoploss isn't True, and freqtrade only calls it when that flag is set -- the method never runs and every trade uses the static stoploss |
ran by Ron · took s
Lookahead analysis
freqtrade lookahead-analysis: detects strategies peeking at future candles.