Appearance
Personalize your experience
Entropy Order Breakout
Admin's ChoiceFreeJoins trends the moment return entropy turns ordered
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
Joins a trend at the moment the market becomes ordered. The Shannon entropy of recent returns falls when moves start to repeat; the first bar it drops below the order level, the strategy enters in the direction of an adaptive average's slope, and it rides the move with a trailing stop until the market turns random again. Entry: entropy crosses below the order level, adaptive mean sloping, close on the right side of it. Exit: ATR trailing stop, or entropy back above the disorder level. Risk: 1 % per trade. Method: Shannon (1948) entropy of the return histogram.
Settings
Entropy window: 60
Histogram bins: 10
Order level: 0.86
Disorder level: 0.93
Adaptive mean: 34
Trailing stop (ATR): 2.2
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
- ▸ entropy crosses below the order level, adaptive mean sloping, close on the right side of it
Exit Conditions
- ▸ ATR trailing stop, or entropy back above the disorder level
Measured backtest
BTCUSDT 1h (Binance), 2025-11-01 to 2026-11-01 · backtest engine, script costs included
10.8%
Return
0.63
Sharpe
-16.4%
Max DD
14.3%
Win Rate
35
Trades
| Market | Trades | Return | Sharpe | Max DD | Win rate | Profit factor |
|---|---|---|---|---|---|---|
| BTCUSDT 1h | 35 | 10.8% | 0.63 | -16.4% | 14.3% | 1.34 |
| ETHUSDT 1h | 37 | -12.5% | -0.40 | -23.7% | 5.4% | 0.28 |
Past results on historical data do not predict future returns.
Source Code
Edit in IDE| 1 | strategy "Entropy Order Breakout" { |
| 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 | /// Joins a trend at the moment the market becomes ordered. The Shannon entropy of recent returns |
| 12 | /// falls when moves start to repeat; the first bar it drops below the order level, the strategy |
| 13 | /// enters in the direction of an adaptive average's slope, and it rides the move with a trailing |
| 14 | /// stop until the market turns random again. |
| 15 | /// Entry: entropy crosses below the order level, adaptive mean sloping, close on the right side of |
| 16 | /// it. Exit: ATR trailing stop, or entropy back above the disorder level. |
| 17 | /// Risk: 1 % per trade. Method: Shannon (1948) entropy of the return histogram. |
| 18 | use "viz/premium" as pr |
| 19 | len = param.int(60, title = "Entropy window", min = 20, max = 1000, group = "Entropy") |
| 20 | bins = param.int(10, title = "Histogram bins", min = 4, max = 40, group = "Entropy") |
| 21 | order_lv = param.float(0.86, title = "Order level", min = 0.3, max = 0.99, step = 0.01, group = "Entropy") |
| 22 | chaos_lv = param.float(0.93, title = "Disorder level", min = 0.4, max = 1, step = 0.01, group = "Entropy") |
| 23 | mean_l = param.int(34, title = "Adaptive mean", min = 5, max = 400, group = "Trend") |
| 24 | stop_k = param.float(2.2, title = "Trailing stop (ATR)", min = 0.5, max = 8, step = 0.1, group = "Risk") |
| 25 | e = stat.entropy(math.log(close / close[1]), len, bins) |
| 26 | c = ta.kaufman(close, mean_l) |
| 27 | a = ta.atr(20) |
| 28 | up = c > c[1] |
| 29 | ordered = e < order_lv and e[1] >= order_lv |
| 30 | flat = position.size == 0 |
| 31 | if flat and ordered and up and close > c { |
| 32 | order.market("L", side.long) |
| 33 | exit.bracket("L exit", entry = "L", stop = close - stop_k * a, trail_offset = stop_k * a, trail_trigger = close) |
| 34 | } |
| 35 | if flat and ordered and not up and close < c { |
| 36 | order.market("S", side.short) |
| 37 | exit.bracket("S exit", entry = "S", stop = close + stop_k * a, trail_offset = stop_k * a, trail_trigger = close) |
| 38 | } |
| 39 | if position.size != 0 and e > chaos_lv { exit.close_all() } |
| 40 | risk.max_drawdown(25) |
| 41 | render.line(c, "Adaptive mean", color = e < order_lv ? (up ? color.cyan.300 : color.fuchsia.300) : color.slate.500, width = 2) |
| 42 | render.mark(ordered, shape = shape.diamond, at = anchor.above_bar, color = color.amber.300, size = 0.5, title = "Market turns ordered") |
| 43 | persist t = draw.table.create(anchor.top_right, 4, 2) |
| 44 | if bar.is_last { |
| 45 | pr.heading(t, 2, "Entropy Order Breakout", "Strategy · Shannon entropy") |
| 46 | pr.row(t, 2, "Entropy", str.format("{:.3f}", e), e < order_lv ? pr.BULL : pr.LABEL) |
| 47 | pr.row(t, 3, "Market", e < order_lv ? "Ordered" : e > chaos_lv ? "Random" : "Mixed", color.white) |
| 48 | } |
| 49 |
Reviews
No reviews yet. Be the first to review this listing.