Short term volatility breakout strategy that works well on indices
![]()
//@version=5
strategy("Volatility Expansion Breakout",
overlay=true,
initial_capital=100000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=1)
// === Inputs ===
htf = input.timeframe("60", "Higher Timeframe")
emaLen = input.int(200, "HTF EMA Length")
atrLen = input.int(14, "ATR Length")
atrMult = input.float(2.0, "ATR Trail Multiplier")
rangeLen = input.int(20, "Breakout Range Length")
// === Higher Timeframe Bias ===
htfClose = request.security(syminfo.tickerid, htf, close)
htfEMA = request.security(syminfo.tickerid, htf, ta.ema(close, emaLen))
bullBias = htfClose > htfEMA
bearBias = htfClose < htfEMA
// === Volatility ===
atr = ta.atr(atrLen)
atrRising = atr > atr[1]
// === Breakout Levels ===
rangeHigh = ta.highest(high, rangeLen)
rangeLow = ta.lowest(low, rangeLen)
// === Entries ===
longCondition = bullBias and atrRising and close > rangeHigh[1]
shortCondition = bearBias and atrRising and close < rangeLow[1]
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
// === Trailing Stop ===
longTrail = close - atr * atrMult
shortTrail = close + atr * atrMult
strategy.exit("Long Exit", from_entry="Long", trail_price=longTrail, trail_offset=atr*atrMult)
strategy.exit("Short Exit", from_entry="Short", trail_price=shortTrail, trail_offset=atr*atrMult)