Appearance
Personalize your experience
Mode
Accent Color
Direction
Adaptive Band Breakout
FreeBreakouts of volatility-percentile ATR bands with the slope
0.0(0)
0 installs 0 0 commentsQ
quascriptstrategyatrbreakout
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.
Adaptive Band Breakoutengine result
Loading the engine result…
quatick-charts · QuaScript engine on synthetic 1-minute bars · drag to pan · scroll to zoom · Run executes the script on the engine (⌘/Ctrl+Enter while editing)
About
Closes beyond ATR bands whose width adapts to the volatility percentile, taken in the direction of the basis slope; exits on a close back through the basis or at the ATR stop.
Settings
Basis length: 34
Tight multiplier: 1.2
Wide multiplier: 3
Stop (ATR): 2
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 IDEquascript
| 1 | strategy "Adaptive Band 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 | /// Closes beyond ATR bands whose width adapts to the volatility percentile, taken in the direction |
| 11 | /// of the basis slope; exits on a close back through the basis or at the ATR stop. |
| 12 | len = param.int(34, title = "Basis length", min = 2, max = 500) |
| 13 | lo_k = param.float(1.2, title = "Tight multiplier", min = 0.2, max = 10, step = 0.1) |
| 14 | hi_k = param.float(3.0, title = "Wide multiplier", min = 0.5, max = 15, step = 0.1) |
| 15 | stopk = param.float(2.0, title = "Stop (ATR)", min = 0.5, max = 10, step = 0.1) |
| 16 | basis = ta.ema(close, len) |
| 17 | a = ta.atr(len) |
| 18 | rank = stat.percent_rank(a, 250) / 100 |
| 19 | k = lo_k + (hi_k - lo_k) * math.coalesce(rank, 0.5) |
| 20 | up = basis + k * a |
| 21 | dn = basis - k * a |
| 22 | flat = position.size == 0 |
| 23 | if flat and close > up and basis > basis[1] and not math.is_na(a) { |
| 24 | order.market("L", side.long) |
| 25 | exit.bracket("L stop", entry = "L", stop = close - stopk * a) |
| 26 | } |
| 27 | if flat and close < dn and basis < basis[1] and not math.is_na(a) { |
| 28 | order.market("S", side.short) |
| 29 | exit.bracket("S stop", entry = "S", stop = close + stopk * a) |
| 30 | } |
| 31 | if position.size > 0 and close < basis { exit.close_all() } |
| 32 | if position.size < 0 and close > basis { exit.close_all() } |
| 33 | risk.max_drawdown(25) |
| 34 | pu = render.line(up, "Upper", color = color.translucent(color.rose.300, 40), width = 1) |
| 35 | render.line(basis, "Basis", color = color.amber.300, width = 1.5) |
| 36 | pd = render.line(dn, "Lower", color = color.translucent(color.emerald.300, 40), width = 1) |
| 37 | render.band(pu, pd, color = color.indigo.500, opacity = 0.05, title = "Adaptive band") |
| 38 |
Read-only preview. Open in QuaCode to edit and deploy.
Reviews
No reviews yet. Be the first to review this listing.
Discussion
Sign in to join the discussion. Your posts and replies show up on your profile.