Appearance
Personalize your experience
Compression Release
FreeRanked compression release with regression thrust
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 the expansion that follows a ranked volatility compression. Compression is the mean of two percentile ranks (Bollinger width and short-term range against ATR); a release is the first bar the score leaves the compressed zone, and the side comes from the slope of a short regression measured in ATR per bar, so only directional releases are traded. Entry: compression release with thrust beyond the threshold. Exit: stop at the compression range's far side, target `reward` R, trailing after 1R, time stop. Risk: 1 % per trade.
Settings
Width length: 20
Rank window: 250
Compressed above: 80
Thrust length: 12
Release thrust (ATR / bar): 0.08
Target (R): 2.5
Maximum bars held: 60
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
- ▸ compression release with thrust beyond the threshold
Exit Conditions
- ▸ stop at the compression range's far side, target `reward` R, trailing after 1R, time stop
Measured backtest
BTCUSDT 1h (Binance), 2025-11-01 to 2026-11-01 · backtest engine, script costs included
-4.9%
Return
-0.43
Sharpe
-17.4%
Max DD
40.9%
Win Rate
71
Trades
| Market | Trades | Return | Sharpe | Max DD | Win rate | Profit factor |
|---|---|---|---|---|---|---|
| BTCUSDT 1h | 71 | -4.9% | -0.43 | -17.4% | 40.9% | 0.88 |
| ETHUSDT 1h | 62 | -4.2% | -0.33 | -13.1% | 33.9% | 0.89 |
Past results on historical data do not predict future returns.
Source Code
Edit in IDE| 1 | strategy "Compression Release" { |
| 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 the expansion that follows a ranked volatility compression. Compression is the mean of |
| 12 | /// two percentile ranks (Bollinger width and short-term range against ATR); a release is the first |
| 13 | /// bar the score leaves the compressed zone, and the side comes from the slope of a short |
| 14 | /// regression measured in ATR per bar, so only directional releases are traded. |
| 15 | /// Entry: compression release with thrust beyond the threshold. Exit: stop at the compression |
| 16 | /// range's far side, target `reward` R, trailing after 1R, time stop. |
| 17 | /// Risk: 1 % per trade. |
| 18 | use "viz/premium" as pr |
| 19 | len = param.int(20, title = "Width length", min = 5, max = 200, group = "Compression") |
| 20 | rank_len = param.int(250, title = "Rank window", min = 50, max = 2000, group = "Compression") |
| 21 | tight = param.float(80, title = "Compressed above", min = 50, max = 99, group = "Compression") |
| 22 | th_len = param.int(12, title = "Thrust length", min = 3, max = 100, group = "Thrust") |
| 23 | th_min = param.float(0.08, title = "Release thrust (ATR / bar)", min = 0, max = 1, step = 0.01, group = "Thrust") |
| 24 | reward = param.float(2.5, title = "Target (R)", min = 0.5, max = 10, step = 0.1, group = "Risk") |
| 25 | hold = param.int(60, title = "Maximum bars held", min = 2, max = 1000, group = "Risk") |
| 26 | bbw = ta.bollinger_width(close, len, 2) |
| 27 | range_ratio = ta.sma(ta.true_range(), 5) / math.max(ta.atr(len * 5), 1e-12) |
| 28 | score = 100 - (stat.percent_rank(bbw, rank_len) + stat.percent_rank(range_ratio, rank_len)) / 2 |
| 29 | (_, slope, _) = stat.linreg(close, th_len, 0) |
| 30 | a = ta.atr(len) |
| 31 | thrust = slope / math.max(a, 1e-12) |
| 32 | compressed = score >= tight |
| 33 | box_hi = ta.highest(high, len) |
| 34 | box_lo = ta.lowest(low, len) |
| 35 | released = compressed[1] and not compressed |
| 36 | flat = position.size == 0 |
| 37 | if flat and released and thrust > th_min { |
| 38 | order.market("L", side.long) |
| 39 | exit.bracket("L exit", entry = "L", stop = box_lo, target = close + (close - box_lo) * reward, trail_offset = close - box_lo, trail_trigger = close + (close - box_lo)) |
| 40 | } |
| 41 | if flat and released and thrust < -th_min { |
| 42 | order.market("S", side.short) |
| 43 | exit.bracket("S exit", entry = "S", stop = box_hi, target = close - (box_hi - close) * reward, trail_offset = box_hi - close, trail_trigger = close - (box_hi - close)) |
| 44 | } |
| 45 | if position.size != 0 and position.bars_held >= hold { exit.close_all() } |
| 46 | risk.max_drawdown(25) |
| 47 | ph = render.line(box_hi, "Range high", color = color.translucent(color.violet.300, compressed ? 20 : 70), width = 1) |
| 48 | plo = render.line(box_lo, "Range low", color = color.translucent(color.violet.300, compressed ? 20 : 70), width = 1) |
| 49 | render.band(ph, plo, color = color.translucent(color.violet.500, compressed ? 82 : 98), opacity = 1, title = "Compression box") |
| 50 | render.mark(released and thrust > th_min, shape = shape.arrow_up, at = anchor.below_bar, color = color.cyan.300, text = "Release", title = "Release up") |
| 51 | render.mark(released and thrust < -th_min, shape = shape.arrow_down, at = anchor.above_bar, color = color.pink.300, text = "Release", title = "Release down") |
| 52 | persist t = draw.table.create(anchor.top_right, 4, 2) |
| 53 | if bar.is_last { |
| 54 | pr.heading(t, 2, "Compression Release", "Strategy · ranked squeeze, regression thrust") |
| 55 | pr.row(t, 2, "Compression score", str.format("{:.0f}", score), compressed ? color.violet.300 : color.white) |
| 56 | pr.row(t, 3, "Thrust", str.format("{:+.3f} ATR / bar", thrust), thrust > 0 ? pr.BULL : pr.BEAR) |
| 57 | } |
| 58 |
Reviews
No reviews yet. Be the first to review this listing.