Appearance

Personalize your experience

Mode
Accent Color
Direction
MarketplacestrategiesAdaptive Band Breakout
QuaScript

Adaptive Band Breakout

Free

Breakouts of volatility-percentile ATR bands with the slope

0.0(0)
0 installs 0 0 comments
Q
433 listings

The QuaTick team's QuaScript analyses, run by the native C++ engine.

View Profile
quascriptstrategyatrbreakout
Free
Backtest this strategy Open in QuaCode Edit in IDE
Version
Updated
Compatible

Live engine preview

QuaScriptQuaScript

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 IDE
      quascript
      1strategy "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.
      12len = param.int(34, title = "Basis length", min = 2, max = 500)
      13lo_k = param.float(1.2, title = "Tight multiplier", min = 0.2, max = 10, step = 0.1)
      14hi_k = param.float(3.0, title = "Wide multiplier", min = 0.5, max = 15, step = 0.1)
      15stopk = param.float(2.0, title = "Stop (ATR)", min = 0.5, max = 10, step = 0.1)
      16basis = ta.ema(close, len)
      17a = ta.atr(len)
      18rank = stat.percent_rank(a, 250) / 100
      19k = lo_k + (hi_k - lo_k) * math.coalesce(rank, 0.5)
      20up = basis + k * a
      21dn = basis - k * a
      22flat = position.size == 0
      23if 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}
      27if 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}
      31if position.size > 0 and close < basis { exit.close_all() }
      32if position.size < 0 and close > basis { exit.close_all() }
      33risk.max_drawdown(25)
      34pu = render.line(up, "Upper", color = color.translucent(color.rose.300, 40), width = 1)
      35render.line(basis, "Basis", color = color.amber.300, width = 1.5)
      36pd = render.line(dn, "Lower", color = color.translucent(color.emerald.300, 40), width = 1)
      37render.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.