Code Library / Breakout

Pine Script Volatility Breakout

ATR-based volatility breakout from daily open.

Language: Pine Script · Category: Breakout · Tags: volatility breakout, ATR, Pine Script, strategy, momentum

Source code

//@version=5
strategy("Vol Breakout",overlay=true)
atr=ta.atr(14); mult=input.float(1.5,"ATR Mult")
dO=request.security(syminfo.tickerid,"D",open)
ub=dO+atr*mult; lb=dO-atr*mult
if ta.crossover(close,ub) then strategy.entry("Long",strategy.long)
if ta.crossunder(close,lb) then strategy.entry("Short",strategy.short)
plot(ub,"Upper",color.green,2,plot.style_stepline)
plot(lb,"Lower",color.red,2,plot.style_stepline)
plot(dO,"Open",color.yellow)

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.

Related snippets