5 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 | from datetime import datetime from freqtrade.persistence import Trade from freqtrade.strategy import IStrategy, informative from pandas import DataFrame import numpy import talib.abstract as ta from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter, IStrategy, IntParameter, RealParameter, merge_informative_pair) class Candle2(IStrategy): # Strategy parameters timeframe = "1h" # 5-minute timeframe as per the video example minimal_roi = {} # 1.5% ROI (1:1.5 risk-reward ratio) stoploss = -0.04 # 1% stop loss (adjustable) # Trailing stop: trailing_stop = True # value loaded from strategy trailing_stop_positive = 0.025 # value loaded from strategy trailing_stop_positive_offset = 0.10 # value loaded from strategy trailing_only_offset_is_reached = True # value loaded from strategy buy_threshold = DecimalParameter(3.0, 8.0, default=4.0, decimals=1, space="buy") rsi_threshold = DecimalParameter(40.0, 70.0, default=65.0, decimals=1, space="buy") sell_threshold = DecimalParameter(3.0, 4.0, default=4.0, decimals=1, space="sell") sr_length = IntParameter(12, 50, default=24, space="buy") sr_shift = IntParameter(12, 50, default=24, space="buy") fast_rsi = IntParameter(4, 20, default=12, space="buy") @informative('4h') def populate_indicators_4h(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # Calculate candle range (high - low) dataframe['range'] = dataframe['high'] - dataframe['low'] dataframe['range_third'] = dataframe['range'] / 3 # Close position: Determine if close is in upper, mid, or lower third dataframe['close_position'] = 0 # Default: mid dataframe.loc[dataframe['close'] > (dataframe['high'] - dataframe['range_third']), 'close_position'] = 1 # High close dataframe.loc[dataframe['close'] < (dataframe['low'] + dataframe['range_third']), 'close_position'] = -1 # Low close # Close comparison: Compare current close to previous candle's range dataframe['prev_high'] = dataframe['high'].shift(1) dataframe['prev_low'] = dataframe['low'].shift(1) dataframe['close_comparison'] = 0 # Default: range dataframe.loc[dataframe['close'] > dataframe['prev_high'], 'close_comparison'] = 1 # Bull candle dataframe.loc[dataframe['close'] < dataframe['prev_low'], 'close_comparison'] = -1 # Bear candle dataframe['CO2'] = ((dataframe['close'] - dataframe['open']) / 2) + dataframe['open'] # Combine close position and close comparison into 9 patterns dataframe['pattern'] = dataframe['close_position'] * 3 + dataframe['close_comparison'] + 4 # Maps to 0-8 (9 patterns) dataframe['rsi'] = ta.RSI(dataframe, timeperiod=6) return dataframe # Define custom variables def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # Calculate candle range (high - low) dataframe['range'] = dataframe['high'] - dataframe['low'] dataframe['range_third'] = dataframe['range'] / 3 # Close position: Determine if close is in upper, mid, or lower third dataframe['close_position'] = 0 # Default: mid dataframe.loc[dataframe['close'] > (dataframe['high'] - dataframe['range_third']), 'close_position'] = 1 # High close dataframe.loc[dataframe['close'] < (dataframe['low'] + dataframe['range_third']), 'close_position'] = -1 # Low close # Close comparison: Compare current close to previous candle's range dataframe['prev_high'] = dataframe['high'].shift(1) dataframe['prev_low'] = dataframe['low'].shift(1) dataframe['close_comparison'] = 0 # Default: range dataframe.loc[dataframe['close'] > dataframe['prev_high'], 'close_comparison'] = 1 # Bull candle dataframe.loc[dataframe['close'] < dataframe['prev_low'], 'close_comparison'] = -1 # Bear candle # Combine close position and close comparison into 9 patterns dataframe['pattern'] = dataframe['close_position'] * 3 + dataframe['close_comparison'] + 4 # Maps to 0-8 (9 patterns) dataframe['pattern_avg'] = ((dataframe['pattern'] + dataframe['pattern_4h']) / 2).rolling(2).mean() # Simple support/resistance levels using rolling min/max dataframe['support'] = dataframe['low_4h'].rolling(window=self.sr_length.value).min().shift(self.sr_shift.value) dataframe['resistance'] = dataframe['high_4h'].rolling(window=self.sr_length.value).max().shift(self.sr_shift.value) # 4h S/R dataframe['range_4h'] = dataframe['resistance'] - dataframe['support'] dataframe['inflection'] = (dataframe['range_4h']/2) + dataframe['support'] dataframe['range_third_4h'] = dataframe['range_4h'] / 3 # Close position: Determine if close is in upper, mid, or lower third dataframe['CO2_position'] = 0 # Default: mid dataframe.loc[dataframe['CO2_4h'] > (dataframe['resistance'] - dataframe['range_third_4h']), 'CO2_position'] = 1 # High close dataframe.loc[dataframe['CO2_4h'] < (dataframe['support'] + dataframe['range_third_4h']), 'CO2_position'] = -1 # Low close # Close comparison: Compare current close to previous candle's range dataframe['prev_high_4h'] = dataframe['resistance'].shift(1) dataframe['prev_low_4h'] = dataframe['support'].shift(1) dataframe['close_c'] = 0 dataframe.loc[dataframe['close'] > dataframe['close_4h'].shift(4), 'close_c'] = 1 # Bull candle dataframe.loc[dataframe['close'] < dataframe['close_4h'].shift(4), 'close_c'] = -1 # Bear candle dataframe['rsi'] = ta.RSI(dataframe, timeperiod=self.fast_rsi.value) # # Combine close position and close comparison into 9 patterns dataframe['pattern_CO2'] = dataframe['CO2_position'] * 3 + dataframe['close_c'] + 4 # Maps to 0-8 (9 patterns) dataframe['bull_bear'] = 0 dataframe.loc[dataframe['CO2_4h'] < dataframe['close'], 'bull_bear'] = 1 # High close dataframe.loc[dataframe['CO2_4h'] > dataframe['close'], 'bull_bear'] = -1 # Low close # timestamp = datetime.now().strftime('%Y-%m-%d_%H%M') # pair = metadata['pair'].replace('/', '_') # Replace '/' with '_' for valid filename # filename = f"{pair}_{timestamp}.csv" # dataframe.to_csv(filename, index=True) # logger.info(f"Exported DataFrame for {pair} to {filename}") return dataframe def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # Buy conditions based on Two Candle Theory dataframe.loc[ ( # High close bull candle (pattern 4: most bullish) (dataframe['pattern_avg'] >= self.buy_threshold.value) & (dataframe['pattern_avg'].shift() < 8) & (dataframe['rsi_4h'] < self.rsi_threshold.value) & (dataframe['rsi'] > dataframe['rsi_4h']) # Breakout above resistance # (dataframe['close'] > dataframe['resistance'].shift(1)) & # Previous candle was not bearish (avoid false breakouts) # (dataframe['pattern'].shift(1) != 0) # Not low close bear ), ['enter_long', 'enter_tag']] = (1, 'Pattern and RSI') dataframe.loc[ ( # High close bull candle (pattern 4: most bullish) (dataframe['pattern_avg'] >= self.buy_threshold.value) & (dataframe['pattern_avg'].shift() < 8) & (dataframe['CO2_4h'] > dataframe['resistance']) & (dataframe['CO2_4h'].shift() < dataframe['resistance'].shift()) & (dataframe['rsi_4h'] < self.rsi_threshold.value) & (dataframe['rsi'] > dataframe['rsi_4h']) # Breakout above resistance # (dataframe['close'] > dataframe['resistance'].shift(1)) & # Previous candle was not bearish (avoid false breakouts) # (dataframe['pattern'].shift(1) != 0) # Not low close bear ), ['enter_long', 'enter_tag']] = (1, 'Resistance Cross') dataframe.loc[ ( # High close bull candle (pattern 4: most bullish) (dataframe['pattern_avg'] >= self.buy_threshold.value) & # (dataframe['pattern_avg'].shift() < 8) & (dataframe['CO2_4h'] > dataframe['support']) & (dataframe['CO2_4h'].shift() < dataframe['support'].shift()) # (dataframe['rsi_4h'] < self.rsi_threshold.value) # (dataframe['rsi'] > dataframe['rsi_4h']) # Breakout above resistance # (dataframe['close'] > dataframe['resistance'].shift(1)) & # Previous candle was not bearish (avoid false breakouts) # (dataframe['pattern'].shift(1) != 0) # Not low close bear ), ['enter_long', 'enter_tag']] = (1, 'Support Cross') dataframe.loc[ ( # High close bull candle (pattern 4: most bullish) (dataframe['pattern_avg'] >= self.buy_threshold.value) & # (dataframe['pattern_avg'].shift() < 8) & (dataframe['CO2_4h'] < dataframe['support']) & (dataframe['CO2_4h'].shift(4) < dataframe['CO2_4h']) & # (dataframe['rsi_4h'] < self.rsi_threshold.value) (dataframe['rsi'] > dataframe['rsi_4h']) # Breakout above resistance # (dataframe['close'] > dataframe['resistance'].shift(1)) & # Previous candle was not bearish (avoid false breakouts) # (dataframe['pattern'].shift(1) != 0) # Not low close bear ), ['enter_long', 'enter_tag']] = (1, 'Below Support 4h pull up') dataframe.loc[ ( # High close bull candle (pattern 4: most bullish) # (dataframe['pattern_avg'] >= self.buy_threshold.value) & # (dataframe['pattern_avg'].shift() < 8) & (dataframe['CO2_4h'] < dataframe['support']) & (dataframe['rsi_4h'] < 10) & (dataframe['rsi'] > dataframe['rsi_4h']) # Breakout above resistance # (dataframe['close'] > dataframe['resistance'].shift(1)) & # Previous candle was not bearish (avoid false breakouts) # (dataframe['pattern'].shift(1) != 0) # Not low close bear ), ['enter_long', 'enter_tag']] = (1, '4h Extreme RSI') # # Alternative buy: High close bull after support bounce # dataframe.loc[ # ( # (dataframe['pattern'] == 4) & # (dataframe['close'] > dataframe['support']) & # (dataframe['pattern'].shift(1) == 0) # Previous was low close bear # ), # 'enter_long'] = 1 # # Sell conditions (short entry) # dataframe.loc[ # ( # # Low close bear candle (pattern 0: most bearish) # (dataframe['pattern'] == 0) & # # Breakdown below support # (dataframe['close'] < dataframe['support'].shift(1)) & # # Previous candle was not bullish (avoid false breakdowns) # (dataframe['pattern'].shift(1) != 4) # Not high close bull # ), # 'enter_short'] = 1 return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # Exit long on strong bearish signal # dataframe.loc[ # # (dataframe['enter_long'].shift(1) == 1) & # (dataframe['pattern_avg'] <= self.sell_threshold.value), # Low close bear candle # 'exit_long'] = 1 # # Exit short on strong bullish signal # dataframe.loc[ # (dataframe['enter_short'].shift(1) == 1) & # (dataframe['pattern'] == 4), # High close bull candle # 'exit_short'] = 1 dataframe.loc[ ( # High close bull candle (pattern 4: most bullish) # (dataframe['pattern_avg'] >= self.buy_threshold.value) & # (dataframe['pattern_avg'].shift() < 8) & (dataframe['CO2_4h'] > dataframe['resistance']) & (dataframe['close'] > dataframe['resistance']) & (dataframe['close'] < dataframe['CO2_4h']) & (dataframe['rsi_4h'] > 85) # (dataframe['rsi'] > dataframe['rsi_4h']) # Breakout above resistance # (dataframe['close'] > dataframe['resistance'].shift(1)) & # Previous candle was not bearish (avoid false breakouts) # (dataframe['pattern'].shift(1) != 0) # Not low close bear ), ['exit_long', 'exit_tag']] = (1, 'Above Resistance 4h') # dataframe.loc[ # ( # # High close bull candle (pattern 4: most bullish) # # (dataframe['pattern_avg'] >= self.buy_threshold.value) & # # (dataframe['pattern_avg'].shift() < 8) & # (dataframe['CO2_4h'] < dataframe['resistance']) & # (dataframe['CO2_4h'].shift() > dataframe['resistance'].shift()) # # (dataframe['rsi'] > dataframe['rsi_4h']) # # Breakout above resistance # # (dataframe['close'] > dataframe['resistance'].shift(1)) & # # Previous candle was not bearish (avoid false breakouts) # # (dataframe['pattern'].shift(1) != 0) # Not low close bear # ), # ['exit_long', 'exit_tag']] = (1, 'Resistance Cross') # dataframe.loc[ # ( # # High close bull candle (pattern 4: most bullish) # # (dataframe['pattern_avg'] >= self.buy_threshold.value) & # # (dataframe['pattern_avg'].shift() < 8) & # (dataframe['CO2_4h'] < dataframe['support']) & # (dataframe['CO2_4h'].shift() > dataframe['support'].shift()) # # (dataframe['rsi'] > dataframe['rsi_4h']) # # Breakout above resistance # # (dataframe['close'] > dataframe['resistance'].shift(1)) & # # Previous candle was not bearish (avoid false breakouts) # # (dataframe['pattern'].shift(1) != 0) # Not low close bear # ), # ['exit_long', 'exit_tag']] = (1, 'Below Support 4h cross') return dataframe |
Strategy League — fixed backtest that feeds the ranking
Export report Freqtrade logsRun finished · took 64.8s
ℹ️ This strategy uses a trailing stop — freqtrade only
re-checks these once per 1h 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=1.00) — hard to tell apart from luck
- only 0% of resampled runs were profitable
- did not beat simply holding the market
- very deep drawdown (-93%)
- profitable across 67% of rolling 3-month windows
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 |
|---|---|---|---|---|---|---|---|---|---|
| May 2021 | bearish trending high vol | 443 | -91.19 | -2.06 | 72 | 371 | 16.3 | -93.42 | 7h 50m |
| Apr 2021 | bearish choppy high vol | 358 | +0.01 | -0.00 | 111 | 247 | 31.0 | -40.31 | 17h 32m |
| Mar 2021 | bullish choppy high vol | 220 | +10.27 | 0.46 | 76 | 144 | 34.5 | -40.12 | 27h 57m |
| Feb 2021 | bullish trending high vol | 522 | -7.62 | -0.15 | 153 | 369 | 29.3 | -39.42 | 10h 58m |
| Jan 2021 | bullish trending high vol | 423 | -1.78 | -0.04 | 132 | 291 | 31.2 | -25.49 | 13h 23m |
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 | |
|---|---|---|---|
| 10 | review | missing_startup_candles | uses recursive indicators (RSI) but startup_candle_count is not set (default 0). Their value at a bar depends on all bars before it, so freqtrade trims no warmup and the backtest opens with unwarmed values that can't occur live. The longest lookback visible here is .shift(4), so it needs at least that many. Set it to a few times the longest period and confirm with `freqtrade recursive-analysis` |
| 111 | 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.