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 | """ ICT/SMC Strategy — Smart Money Concepts for Freqtrade Efficient implementation using vectorized operations 15m timeframe, Binance Futures Core ICT Concepts Implemented: 1. Market Structure (HH/HL/BOS/CHoCH) 2. Liquidity Sweeps 3. Order Blocks (simplified) 4. Fair Value Gaps (simplified) 5. Displacement / Momentum 6. Session Killzones """ from pandas import DataFrame import pandas as pd import talib.abstract as ta import numpy as np from freqtrade.strategy import IStrategy class ICT_SMC_Strategy(IStrategy): INTERFACE_VERSION = 3 timeframe = '15m' can_short = True stoploss = -0.02 trailing_stop = True trailing_stop_positive = 0.005 trailing_stop_positive_offset = 0.012 trailing_only_offset_is_reached = True minimal_roi = {"0": 0.06, "480": 0.04, "1440": 0.02, "4320": 0} max_open_trades = 6 startup_candle_count = 300 process_only_new_candles = True use_exit_signal = False def populate_indicators(self, d: DataFrame, m: dict) -> DataFrame: # ============================================================ # 1. SWING HIGHS/LOWS (vectorized) # ============================================================ # Swing high: candle high > 3 before and 3 after d['swing_high'] = ( (d['high'] > d['high'].shift(1)) & (d['high'] > d['high'].shift(2)) & (d['high'] > d['high'].shift(3)) & (d['high'] >= d['high'].shift(-1)) & (d['high'] >= d['high'].shift(-2)) & (d['high'] >= d['high'].shift(-3)) ) # Swing low: candle low < 3 before and 3 after d['swing_low'] = ( (d['low'] < d['low'].shift(1)) & (d['low'] < d['low'].shift(2)) & (d['low'] < d['low'].shift(3)) & (d['low'] <= d['low'].shift(-1)) & (d['low'] <= d['low'].shift(-2)) & (d['low'] <= d['low'].shift(-3)) ) # Forward-fill last swing high/low values d['last_sh'] = d['high'].where(d['swing_high']).ffill() d['last_sl'] = d['low'].where(d['swing_low']).ffill() # ============================================================ # 2. BREAK OF STRUCTURE (BOS) # ============================================================ # Bull BOS: close breaks above last swing high d['bos_bull'] = d['close'] > d['last_sh'].shift(1) # Bear BOS: close breaks below last swing low d['bos_bear'] = d['close'] < d['last_sl'].shift(1) # CHoCH: BOS after opposite trend (simplified: 2+ BOS in one direction, then opposite BOS) d['bull_count'] = d['bos_bull'].rolling(24).sum() # ~6 hours d['bear_count'] = d['bos_bear'].rolling(24).sum() d['choch_bear'] = d['bos_bear'] & (d['bull_count'].shift(1) >= 2) # bear BOS after bull run d['choch_bull'] = d['bos_bull'] & (d['bear_count'].shift(1) >= 2) # bull BOS after bear run # ============================================================ # 3. LIQUIDITY SWEEPS # ============================================================ # Sweep of 20-bar highs/lows d['hh_20'] = d['high'].rolling(20).max() d['ll_20'] = d['low'].rolling(20).min() # High sweep: price hits 20-bar high then closes back below d['sweep_high'] = (d['high'] >= d['hh_20'].shift(1) * 0.998) & (d['close'] < d['hh_20'].shift(1) * 0.997) # Low sweep: price hits 20-bar low then closes back above d['sweep_low'] = (d['low'] <= d['ll_20'].shift(1) * 1.002) & (d['close'] > d['ll_20'].shift(1) * 1.003) # Sweep of previous candle extremes d['sweep_prev_high'] = (d['high'] > d['high'].shift(1)) & (d['close'] < d['high'].shift(1)) d['sweep_prev_low'] = (d['low'] < d['low'].shift(1)) & (d['close'] > d['low'].shift(1)) # ============================================================ # 4. ORDER BLOCKS (simplified: last opposite candle before displacement) # ============================================================ # Displacement: candle body > 2x 20-period average body d['body'] = (d['close'] - d['open']).abs() d['avg_body'] = d['body'].rolling(20).mean() d['displacement_up'] = (d['close'] > d['open']) & (d['body'] > d['avg_body'] * 1.8) d['displacement_down'] = (d['close'] < d['open']) & (d['body'] > d['avg_body'] * 1.8) d['displacement'] = d['displacement_up'] | d['displacement_down'] # Bull OB: bear candle before displacement up = reversal zone d['ob_bull'] = d['displacement_up'] & (d['close'].shift(1) < d['open'].shift(1)) # Bear OB: bull candle before displacement down d['ob_bear'] = d['displacement_down'] & (d['close'].shift(1) > d['open'].shift(1)) # OB candle range becomes potential entry zone d['ob_bull_high'] = np.where(d['ob_bull'], d['high'].shift(1), np.nan) d['ob_bull_low'] = np.where(d['ob_bull'], d['low'].shift(1), np.nan) d['ob_bear_high'] = np.where(d['ob_bear'], d['high'].shift(1), np.nan) d['ob_bear_low'] = np.where(d['ob_bear'], d['low'].shift(1), np.nan) # OB retest: price returns to OB zone within 12 candles of OB formation d['ob_bull_retest'] = False d['ob_bear_retest'] = False for lookback in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]: d['ob_bull_retest'] = d['ob_bull_retest'] | ( d['ob_bull'].shift(lookback) & (d['low'] <= d['ob_bull_high'].shift(lookback)) & (d['close'] >= d['ob_bull_low'].shift(lookback)) ) d['ob_bear_retest'] = d['ob_bear_retest'] | ( d['ob_bear'].shift(lookback) & (d['high'] >= d['ob_bear_low'].shift(lookback)) & (d['close'] <= d['ob_bear_high'].shift(lookback)) ) # ============================================================ # 5. FAIR VALUE GAP (FVG) — simplified vectorized # ============================================================ # Bull FVG: C[2] low > C[0] high → unfilled gap d['fvg_bull'] = d['low'].shift(2) > d['high'].shift(0) * 1.002 d['fvg_bear'] = d['high'].shift(2) < d['low'].shift(0) * 0.998 # FVG retest within 12 candles d['fvg_bull_retest'] = False d['fvg_bear_retest'] = False for lb in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]: d['fvg_bull_retest'] = d['fvg_bull_retest'] | ( d['fvg_bull'].shift(lb) & (d['low'] <= d['high'].shift(lb - 2)) ) d['fvg_bear_retest'] = d['fvg_bear_retest'] | ( d['fvg_bear'].shift(lb) & (d['high'] >= d['low'].shift(lb - 2)) ) # ============================================================ # 6. FIBONACCI / OTE ZONE # ============================================================ # Use rolling 96-period (1 day) swing high/low for fib levels d['swing_high_96'] = d['high'].rolling(96).max() d['swing_low_96'] = d['low'].rolling(96).min() swing_range = d['swing_high_96'] - d['swing_low_96'] d['fib_062'] = d['swing_high_96'] - swing_range * 0.618 # OTE entry d['fib_079'] = d['swing_high_96'] - swing_range * 0.786 # OTE boundary d['fib_062_s'] = d['swing_low_96'] + swing_range * 0.618 # Short OTE d['fib_079_s'] = d['swing_low_96'] + swing_range * 0.786 # In OTE zone for long: price between 0.62 and 0.79 retrace d['in_ote_long'] = (d['close'] >= d['fib_079']) & (d['close'] <= d['fib_062']) d['in_ote_short'] = (d['close'] >= d['fib_062_s']) & (d['close'] <= d['fib_079_s']) # ============================================================ # 7. TRADITIONAL INDICATORS # ============================================================ d['e20'] = ta.EMA(d, timeperiod=20) d['e50'] = ta.EMA(d, timeperiod=50) d['rsi'] = ta.RSI(d, timeperiod=14) d['atr'] = ta.ATR(d, timeperiod=14) d['vr'] = d['volume'] / ta.SMA(d['volume'], timeperiod=20) # ============================================================ # 8. KILLZONE — London/NY session # ============================================================ d['hour'] = pd.to_datetime(d['date']).dt.hour d['in_killzone'] = d['hour'].between(7, 9) | d['hour'].between(12, 14) return d def populate_entry_trend(self, d: DataFrame, m: dict) -> DataFrame: # ===== ICT LONG ENTRY ===== # Structure: channel_h/bos_bull/choch_bull confirming uptrend structure_bull = d['bos_bull'] | d['close'] > d['e50'] # Setup: liquidity sweep below recent low (stop hunt) + OB/FVG entry entry_setup_long = ( d['sweep_low'] | d['sweep_prev_low'] ) & ( d['ob_bull_retest'] | d['fvg_bull_retest'] | d['in_ote_long'] ) # Confirmation: displacement + RSI confirm_long = ( d['displacement_up'] & d['rsi'].between(30, 70) & d['vr'] > 0.6 ) d.loc[ structure_bull & entry_setup_long & confirm_long & (d['volume'] > 0), ['enter_long', 'enter_tag'] ] = (1, 'ICT_L') # ===== ICT SHORT ENTRY ===== structure_bear = d['bos_bear'] | d['close'] < d['e50'] entry_setup_short = ( d['sweep_high'] | d['sweep_prev_high'] ) & ( d['ob_bear_retest'] | d['fvg_bear_retest'] | d['in_ote_short'] ) confirm_short = ( d['displacement_down'] & d['rsi'].between(30, 70) & d['vr'] > 0.6 ) d.loc[ structure_bear & entry_setup_short & confirm_short & (d['volume'] > 0), ['enter_short', 'enter_tag'] ] = (1, 'ICT_S') return d def populate_exit_trend(self, d: DataFrame, m: dict) -> DataFrame: return d |
Strategy League — fixed backtest that feeds the ranking
Export report Freqtrade logsRun finished · took 147.6s
ℹ️ This strategy uses a trailing stop — 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
- very deep drawdown (-90%)
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 2021 | bearish trending high vol | 124 | -4.73 | -0.37 | 67 | 57 | 54.0 | -90.04 | 3h 37m |
| Nov 2021 | bearish trending high vol | 133 | -3.10 | -0.25 | 77 | 56 | 57.9 | -85.75 | 3h 45m |
| Oct 2021 | bullish trending high vol | 168 | -1.31 | -0.10 | 108 | 60 | 64.3 | -82.9 | 3h 19m |
| Sep 2021 | bearish trending high vol | 234 | -4.96 | -0.21 | 140 | 94 | 59.8 | -81.61 | 2h 33m |
| Aug 2021 | bullish trending high vol | 306 | -4.14 | -0.13 | 193 | 113 | 63.1 | -79.12 | 2h 18m |
| Jul 2021 | bullish trending high vol | 368 | -8.61 | -0.23 | 216 | 152 | 58.7 | -71.82 | 2h 43m |
| Jun 2021 | bearish trending high vol | 456 | -13.19 | -0.30 | 263 | 193 | 57.7 | -63.22 | 1h 34m |
| May 2021 | bearish trending high vol | 560 | +4.39 | 0.09 | 352 | 208 | 62.9 | -55.83 | 0h 55m |
| Apr 2021 | bearish choppy high vol | 546 | -12.34 | -0.23 | 321 | 225 | 58.8 | -54.42 | 1h 42m |
| Mar 2021 | bullish choppy high vol | 555 | -15.41 | -0.29 | 324 | 231 | 58.4 | -42.09 | 2h 30m |
| Feb 2021 | bullish trending high vol | 558 | -9.63 | -0.18 | 332 | 226 | 59.5 | -27.32 | 1h 06m |
| Jan 2021 | bullish trending high vol | 691 | -16.98 | -0.25 | 410 | 281 | 59.3 | -18.42 | 1h 09m |
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
6 potential lookahead pattern(s) found · 1 to review
| Line | Pattern | Detail | |
|---|---|---|---|
| 50 | leak | negative_shift | shift() with negative periods reads future candles |
| 59 | |||
| 49 | |||
| 58 | |||
| 48 | |||
| 57 | |||
| 202 | review | enter_tag_overwrite | enter_tag/exit_tag is written by 2 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.