Appearance
Personalize your experience
Vacuum Breakout
FreeRange breakouts taken only inside an order book liquidity vacuum
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
Range breakouts taken only when the order book around the price is unusually thin (a liquidity vacuum: resting size within the band far below its own history), so there is little to stop the move. Stop at the other side of the half range, target a multiple of the risk. Needs the order book (L2): trades only on bars with a recorded book.
Settings
Band around mid (%): 0.5
Vacuum z-score: -1
Breakout range (bars): 20
Reward / risk: 2.5
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
Exit Conditions
Source Code
Edit in IDE| 1 | strategy "Vacuum Breakout" { |
| 2 | overlay = true |
| 3 | capital = 100000 |
| 4 | commission = 0.05 |
| 5 | slippage = 1 |
| 6 | sizing = risk_percent |
| 7 | size = 1 |
| 8 | max_leverage = 1 |
| 9 | } |
| 10 | /// Range breakouts taken only when the order book around the price is unusually thin (a liquidity |
| 11 | /// vacuum: resting size within the band far below its own history), so there is little to stop the |
| 12 | /// move. Stop at the other side of the half range, target a multiple of the risk. |
| 13 | /// Needs the order book (L2): trades only on bars with a recorded book. |
| 14 | pct = param.float(0.5, title = "Band around mid (%)", min = 0.02, max = 5, step = 0.01) |
| 15 | z_vac = param.float(-1.0, title = "Vacuum z-score", min = -4, max = 0, step = 0.1) |
| 16 | brk = param.int(20, title = "Breakout range (bars)", min = 3, max = 500) |
| 17 | rr = param.float(2.5, title = "Reward / risk", min = 0.5, max = 10, step = 0.1) |
| 18 | z = stat.zscore(math.log(math.max(book.liquidity(pct), 1e-12)), 200) |
| 19 | vac = z < z_vac |
| 20 | hi_n = ta.highest(high, brk) |
| 21 | lo_n = ta.lowest(low, brk) |
| 22 | hh = hi_n[1] |
| 23 | ll = lo_n[1] |
| 24 | mid = (hh + ll) / 2 |
| 25 | flat = position.size == 0 |
| 26 | if flat and vac and close > hh { |
| 27 | order.market("L", side.long) |
| 28 | exit.bracket("L exit", entry = "L", stop = mid, target = close + rr * (close - mid)) |
| 29 | } |
| 30 | if flat and vac and close < ll { |
| 31 | order.market("S", side.short) |
| 32 | exit.bracket("S exit", entry = "S", stop = mid, target = close - rr * (mid - close)) |
| 33 | } |
| 34 | risk.max_drawdown(25) |
| 35 | pu = render.line(hh, "Range high", color = color.translucent(color.violet.300, 40), width = 1) |
| 36 | pd = render.line(ll, "Range low", color = color.translucent(color.violet.300, 40), width = 1) |
| 37 | render.band(pu, pd, color = vac ? color.violet.500 : color.slate.600, opacity = 0.07, title = "Range") |
| 38 | render.background(vac ? color.translucent(color.violet.500, 90) : na) |
| 39 |
Reviews
No reviews yet. Be the first to review this listing.