Appearance
Personalize your experience
Fractal Trend Rider
FreeEMA crosses filtered by the fractal dimension of price
Live engine preview
The QuaScript engine's own output on the chart the terminal uses. Change the settings or edit the code and press Run to recompute it.
About
Trades moving-average crosses only when the price path is smooth enough to trend. The Sevcik fractal dimension of price is low (near 1) for a clean trend and high (near 2) for chop; crosses in choppy conditions, where most whipsaws come from, are skipped. Entry: fast EMA crosses the slow EMA while the fractal dimension is below the trend level. Exit: opposite cross, ATR trailing stop, or the path turning choppy. Risk: 1 % per trade. Method: Sevcik (1998) fractal dimension.
Settings
Fast EMA: 21
Slow EMA: 55
Fractal window: 40
Trend level: 1.38
Trailing stop (ATR): 2.5
Measured backtests
Run by the backtest engine on public candles, 2025-11-01 to 2026-11-01, with the script's own commission and slippage, on BTCUSDT 1h (Binance) and ETHUSDT 1h (Binance). The figures per market are in the Measured backtest panel below. Past results do not predict future returns.
Backtest it yourself
Open it on the backtesting page to run it on any symbol, interval and date range, then use Monte Carlo, optimisation, walk-forward and robustness tests.
Strategy Rules
Entry Conditions
- ▸ fast EMA crosses the slow EMA while the fractal dimension is below the trend level
Exit Conditions
- ▸ opposite cross, ATR trailing stop, or the path turning choppy
Measured backtest
BTCUSDT 1h (Binance), 2025-11-01 to 2026-11-01 · backtest engine, script costs included
-18.6%
Return
-1.05
Sharpe
-25.4%
Max DD
15.6%
Win Rate
128
Trades
| Market | Trades | Return | Sharpe | Max DD | Win rate | Profit factor |
|---|---|---|---|---|---|---|
| BTCUSDT 1h | 128 | -18.6% | -1.05 | -25.4% | 15.6% | 0.67 |
| ETHUSDT 1h | 138 | -1.9% | 0.02 | -25.2% | 15.9% | 0.97 |
Past results on historical data do not predict future returns.
Source Code
Edit in IDE| 1 | strategy "Fractal Trend Rider" { |
| 2 | overlay = true |
| 3 | capital = 100000 |
| 4 | commission = 0.05 |
| 5 | slippage = 1 |
| 6 | sizing = risk_percent |
| 7 | max_leverage = 1 |
| 8 | size = 1 |
| 9 | pyramiding = 1 |
| 10 | } |
| 11 | /// Trades moving-average crosses only when the price path is smooth enough to trend. The Sevcik |
| 12 | /// fractal dimension of price is low (near 1) for a clean trend and high (near 2) for chop; crosses |
| 13 | /// in choppy conditions, where most whipsaws come from, are skipped. |
| 14 | /// Entry: fast EMA crosses the slow EMA while the fractal dimension is below the trend level. |
| 15 | /// Exit: opposite cross, ATR trailing stop, or the path turning choppy. |
| 16 | /// Risk: 1 % per trade. Method: Sevcik (1998) fractal dimension. |
| 17 | use "viz/premium" as pr |
| 18 | fast_l = param.int(21, title = "Fast EMA", min = 2, max = 200, group = "Trend") |
| 19 | slow_l = param.int(55, title = "Slow EMA", min = 5, max = 500, group = "Trend") |
| 20 | fd_len = param.int(40, title = "Fractal window", min = 10, max = 500, group = "Filter") |
| 21 | fd_max = param.float(1.38, title = "Trend level", min = 1.05, max = 1.9, step = 0.01, group = "Filter") |
| 22 | stop_k = param.float(2.5, title = "Trailing stop (ATR)", min = 0.5, max = 8, step = 0.1, group = "Risk") |
| 23 | f = ta.ema(close, fast_l) |
| 24 | s = ta.ema(close, slow_l) |
| 25 | fd = stat.fractal_dim(close, fd_len) |
| 26 | a = ta.atr(20) |
| 27 | smooth = fd < fd_max |
| 28 | up_x = ta.cross_up(f, s) |
| 29 | dn_x = ta.cross_down(f, s) |
| 30 | if up_x and smooth { |
| 31 | order.market("L", side.long) |
| 32 | exit.bracket("L exit", entry = "L", stop = close - stop_k * a, trail_offset = stop_k * a, trail_trigger = close) |
| 33 | } |
| 34 | if dn_x and smooth { |
| 35 | order.market("S", side.short) |
| 36 | exit.bracket("S exit", entry = "S", stop = close + stop_k * a, trail_offset = stop_k * a, trail_trigger = close) |
| 37 | } |
| 38 | if (position.side > 0 and dn_x) or (position.side < 0 and up_x) { exit.close_all() } |
| 39 | risk.max_drawdown(25) |
| 40 | pf = render.line(f, "Fast EMA", color = smooth ? color.sky.300 : color.slate.500, width = 2) |
| 41 | ps = render.line(s, "Slow EMA", color = color.translucent(color.slate.300, 30), width = 1.5) |
| 42 | render.band(pf, ps, color = color.translucent(f > s ? color.sky.500 : color.rose.500, smooth ? 84 : 96), opacity = 1, title = "Trend ribbon") |
| 43 | persist t = draw.table.create(anchor.top_right, 4, 2) |
| 44 | if bar.is_last { |
| 45 | pr.heading(t, 2, "Fractal Trend Rider", "Strategy · Sevcik dimension filter") |
| 46 | pr.row(t, 2, "Fractal dimension", str.format("{:.3f}", fd), smooth ? pr.BULL : pr.LABEL) |
| 47 | pr.row(t, 3, "Crosses", smooth ? "Taken" : "Skipped (chop)", color.white) |
| 48 | } |
| 49 |
Reviews
No reviews yet. Be the first to review this listing.