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 | from datetime import datetime import pandas as pd import talib.abstract as ta from freqtrade.persistence import Trade from freqtrade.strategy import DecimalParameter, IntParameter, IStrategy, stoploss_from_open from pandas import DataFrame from technical import qtpylib class BollingerBandMeanReversionStrategy(IStrategy): INTERFACE_VERSION = 3 timeframe = "1d" can_short: bool = False minimal_roi = { "0": 100, } stoploss = -0.15 trailing_stop = False use_custom_stoploss = False process_only_new_candles = True use_exit_signal = True exit_profit_only = False ignore_roi_if_entry_signal = False startup_candle_count: int = 240 bb_window = IntParameter(10, 60, default=20, space="buy") bb_stds = DecimalParameter(1.0, 3.5, default=2.0, space="buy") atr_multiplier = DecimalParameter(1.5, 3.0, default=2.0, space="sell") trail_atr_multiplier = DecimalParameter(1.0, 2.0, default=1.5, space="sell") order_types = { "entry": "limit", "exit": "limit", "stoploss": "market", "stoploss_on_exchange": False, } order_time_in_force = { "entry": "GTC", "exit": "GTC", } def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: bb = qtpylib.bollinger_bands( qtpylib.typical_price(dataframe), window=int(self.bb_window.value), stds=float(self.bb_stds.value), ) dataframe["bb_lowerband"] = bb["lower"] dataframe["bb_middleband"] = bb["mid"] dataframe["bb_upperband"] = bb["upper"] dataframe["atr"] = ta.ATR(dataframe, timeperiod=14) dataframe["volume_mean"] = dataframe["volume"].rolling(window=20).mean() return dataframe def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe["enter_long"] = 0 dataframe["enter_short"] = 0 dataframe["enter_tag"] = "" vol_ok = dataframe["volume"] > 0 dataframe.loc[(dataframe["close"] < dataframe["bb_lowerband"]) & vol_ok, ["enter_long", "enter_tag"]] = [ 1, "bb_lower_touch", ] dataframe.loc[(dataframe["close"] > dataframe["bb_upperband"]) & vol_ok, ["enter_short", "enter_tag"]] = [ 1, "bb_upper_touch", ] conflict = (dataframe["enter_long"] == 1) & (dataframe["enter_short"] == 1) dataframe.loc[conflict, ["enter_long", "enter_short", "enter_tag"]] = [0, 0, ""] return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe["exit_long"] = 0 dataframe["exit_short"] = 0 vol_ok = dataframe["volume"] > 0 dataframe.loc[(dataframe["close"] >= dataframe["bb_middleband"]) & vol_ok, "exit_long"] = 1 dataframe.loc[(dataframe["close"] <= dataframe["bb_middleband"]) & vol_ok, "exit_short"] = 1 return dataframe def custom_stoploss( self, pair: str, trade: Trade, current_time: datetime, current_rate: float, current_profit: float, **kwargs ) -> float: try: dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) if dataframe is None or len(dataframe) < 20: return 1.0 if "date" in dataframe.columns: df = dataframe if not pd.api.types.is_datetime64_any_dtype(df["date"]): df = df.copy() df["date"] = pd.to_datetime(df["date"], utc=True, errors="coerce") df = df.dropna(subset=["date"]).sort_values("date") else: df = dataframe.copy() df["date"] = pd.to_datetime(df.index, utc=True, errors="coerce") df = df.dropna(subset=["date"]).sort_values("date") entry_date = pd.Timestamp(trade.open_date_utc) if entry_date.tzinfo is None: entry_date = entry_date.tz_localize("UTC") else: entry_date = entry_date.tz_convert("UTC") hist = df.loc[df["date"] <= entry_date] if hist.empty: return 1.0 entry_row = hist.iloc[-1] atr_at_entry = float(entry_row.get("atr", 0.0) or 0.0) if atr_at_entry <= 0.0 or pd.isna(atr_at_entry): return 1.0 current_atr = float(df["atr"].iloc[-1] or 0.0) if current_atr <= 0.0 or pd.isna(current_atr): return 1.0 initial_mult = float(self.atr_multiplier.value) trail_mult = float(self.trail_atr_multiplier.value) atr_pct_entry = atr_at_entry / float(trade.open_rate) open_relative_stop = -atr_pct_entry * initial_mult if current_profit > 1.5 * atr_pct_entry: trail_distance = current_atr * trail_mult if bool(getattr(trade, "is_short", False)): stop_price = float(current_rate) + float(trail_distance) if stop_price > float(trade.open_rate): stop_price = float(trade.open_rate) open_relative_stop = max( open_relative_stop, (float(trade.open_rate) - stop_price) / float(trade.open_rate) ) else: stop_price = float(current_rate) - float(trail_distance) if stop_price < float(trade.open_rate): stop_price = float(trade.open_rate) open_relative_stop = max(open_relative_stop, (stop_price / float(trade.open_rate)) - 1.0) sl = float(stoploss_from_open(open_relative_stop, current_profit)) if sl <= 0.0: return 1.0 return sl except Exception as e: if hasattr(self, "log"): self.log.error(f"Custom stoploss error for {pair}: {e!s}") return 1.0 def custom_exit( self, pair: str, trade: Trade, current_time: datetime, current_rate: float, current_profit: float, **kwargs ) -> str | None: if current_profit <= 0: return None max_profit = trade.max_profit if hasattr(trade, "max_profit") else current_profit # 只在高盈利位置回撤时才出,给趋势足够空间 if max_profit > 0.40 and (max_profit - current_profit) > 0.15: return "trailing_profit_15pct" if max_profit > 0.20 and (max_profit - current_profit) > 0.10: return "trailing_profit_10pct" return None @property def plot_config(self): return { "main_plot": { "close": {"color": "black"}, "bb_upperband": {"color": "gray", "fill_to": "bb_lowerband"}, "bb_middleband": {"color": "orange"}, "bb_lowerband": {"color": "gray"}, }, "subplots": { "ATR": {"atr": {"color": "white"}}, "Volume": {"volume": {"color": "gray", "type": "bar"}, "volume_mean": {"color": "blue"}}, }, } |
Strategy League — fixed backtest that feeds the ranking
Export report Freqtrade logsRun finished · took 11.1s
ℹ️ This strategy uses custom_stoploss() — freqtrade only
re-checks these once per 1d candle by default, not against the price movement within it.
For a more accurate read, re-run this backtest locally with --timeframe-detail 1m
(or 5m — freqtrade's own docs use 5m detail for an hourly strategy as a lighter
alternative). 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=0.98) — hard to tell apart from luck
- only 0% of resampled runs were profitable
- profitable in only 25% of rolling 3-month windows
- did not beat simply holding the market
- very deep drawdown (-94%)
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 2022 | bearish trending low vol | 2 | -3.03 | -15.13 | 0 | 2 | 0.0 | -94.28 | 240h 00m |
| Nov 2022 | bearish trending high vol | 6 | -3.59 | -5.98 | 2 | 4 | 33.3 | -93.49 | 72h 00m |
| Oct 2022 | bullish choppy low vol | 3 | -1.59 | -5.30 | 1 | 2 | 33.3 | -90.14 | 272h 00m |
| Sep 2022 | bearish choppy high vol | 1 | -0.74 | -7.34 | 0 | 1 | 0.0 | -89.14 | 552h 00m |
| Jul 2022 | bearish trending high vol | 3 | +2.09 | 6.95 | 3 | 0 | 100.0 | -89.48 | 200h 00m |
| Jun 2022 | bearish trending high vol | 8 | -12.13 | -15.15 | 0 | 8 | 0.0 | -89.99 | 63h 00m |
| May 2022 | bearish trending high vol | 47 | -59.11 | -12.57 | 5 | 42 | 10.6 | -84.81 | 74h 33m |
| Apr 2022 | bearish choppy high vol | 9 | -9.94 | -11.04 | 1 | 8 | 11.1 | -45.43 | 336h 00m |
| Mar 2022 | bullish choppy high vol | 4 | +4.18 | 10.44 | 3 | 1 | 75.0 | -40.58 | 288h 00m |
| Feb 2022 | bearish trending high vol | 15 | +1.75 | 1.17 | 9 | 6 | 60.0 | -42.75 | 219h 12m |
| Jan 2022 | bearish trending high vol | 40 | -45.03 | -11.26 | 6 | 34 | 15.0 | -42.92 | 95h 24m |
| Dec 2021 | bearish trending high vol | 20 | -11.01 | -5.50 | 8 | 12 | 40.0 | -15.95 | 248h 24m |
| Nov 2021 | bullish trending high vol | 14 | -5.58 | -3.99 | 6 | 8 | 42.9 | -7.87 | 176h 34m |
| Oct 2021 | bullish trending high vol | 13 | +16.06 | 12.36 | 13 | 0 | 100.0 | -13.74 | 223h 23m |
| Sep 2021 | bearish trending high vol | 11 | +2.86 | 2.59 | 7 | 4 | 63.6 | -15.29 | 185h 27m |
| Jul 2021 | bearish trending high vol | 20 | +13.89 | 6.94 | 15 | 5 | 75.0 | -23.87 | 224h 24m |
| Jun 2021 | bearish trending high vol | 35 | +17.80 | 5.08 | 13 | 22 | 37.1 | -32.68 | 150h 51m |
| May 2021 | bearish trending high vol | 40 | -54.19 | -13.55 | 2 | 38 | 5.0 | -36.04 | 31h 12m |
| Apr 2021 | bearish choppy high vol | 8 | +5.28 | 6.62 | 5 | 3 | 62.5 | -2.87 | 126h 00m |
| Mar 2021 | bullish choppy high vol | 5 | +7.93 | 15.88 | 5 | 0 | 100.0 | 0.0 | 144h 00m |
| Feb 2021 | bullish trending high vol | 1 | +1.80 | 18.02 | 1 | 0 | 100.0 | 0.0 | 168h 00m |
| Jan 2021 | bullish trending high vol | 2 | +41.43 | 206.97 | 2 | 0 | 100.0 | 0.0 | 24h 00m |
Yearly breakdown
| Year | Trades | Profit % | Avg % | Win | Loss | Win % | DD % | Avg dur |
|---|---|---|---|---|---|---|---|---|
| 2022 | 138 | -127.14 | -9.21 | 30 | 108 | 21.7 | -94.28 | 131h 39m |
| 2021 | 169 | +36.27 | 2.14 | 77 | 92 | 45.6 | -36.04 | 149h 58m |
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 · 3 thing(s) worth reviewing before trusting the numbers
| Line | Pattern | Detail | |
|---|---|---|---|
| 92 | 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 |
| 65 | review | short_without_can_short | writes enter_short, exit_short but can_short isn't True, so freqtrade never opens a short (it also requires futures/margin mode). Worse, freqtrade only takes a long when `not any([exit_long, enter_short])`, so every row you mark enter_short SUPPRESSES that candle's long entry and opens nothing in its place. |
| 70 | review | enter_tag_overwrite | enter_tag/exit_tag is written by 3 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.