Volatility is one of the most important market properties a trader can monitor. While many traders rely on standard indicators like Bollinger Bands or ATR alone, the Donchian Volatility Indicator offers a different perspective by combining the Donchian Channel concept with ATR-adaptive boundaries.
This indicator was originally developed for TradingView and has been adapted to ProBuilder for ProRealTime. Instead of plotting the channel on the price chart, it measures the channel width as a standalone oscillator, providing a clean visual representation of volatility expansion and contraction cycles.
The indicator builds on two well-established tools:
The core calculation is straightforward:
Upper Channel = Highest High (N periods) + ATR × Multiplier Lower Channel = Lowest Low (N periods) − ATR × Multiplier Channel Width = Upper Channel − Lower Channel
A signal line (simple moving average of the channel width) is then overlaid to help identify shifts between volatility regimes.
The indicator plots two lines in a separate panel below the price chart:
Background color provides an additional visual cue:
//-----------------------------------------------------------//
//PRC_Donchian Volatility Indicator
//version = 0
//15.05.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-----------------------------------------------------------//
//-----Inputs------------------------------------------------//
length=50//Lookback Period for Donchian Channel
atrPeriod=14//ATR Period
atrMultiplier=2.0//ATR Multiplier
signalPeriod=50//Length of Signal Line
//-----------------------------------------------------------//
//-----Calculate ATR-----------------------------------------//
atr=averagetruerange[atrPeriod](close)
//-----------------------------------------------------------//
//-----Calculate Upper and Lower Channels--------------------//
upperChannel=highest[length](high)+atr*atrMultiplier
lowerChannel=lowest[length](low)-atr*atrMultiplier
//-----------------------------------------------------------//
//-----Calculate Channel Width-------------------------------//
channelWidth=upperChannel-lowerChannel
//-----------------------------------------------------------//
//-----Signal Line-------------------------------------------//
signalLine=average[signalPeriod](channelWidth)
//-----------------------------------------------------------//
//-----Bar Color---------------------------------------------//
if channelWidth>signalLine then
r=0
g=230
b=118
else
r=224
g=64
b=251
endif
//This piece of code works in price chart
//DRAWCANDLE(open, high, low, close) coloured(r,g,b)
//-----------------------------------------------------------//
//-----Background Color--------------------------------------//
BACKGROUNDCOLOR (r,g,b,30)
//-----------------------------------------------------------//
//-----Plotting----------------------------------------------//
return channelWidth as "Channel Width"coloured("maroon")style(line,4),signalLine as "Signal Line"coloured("aqua")style(line,4)
The Donchian Volatility Indicator provides a clean, intuitive way to track volatility cycles by measuring the adaptive width of a Donchian Channel. The combination of the raw channel width with a signal line crossover system makes it easy to identify periods of expanding or contracting volatility at a glance.
The green/pink background coloring adds an extra layer of visual clarity, making regime shifts immediately obvious without needing to study the lines in detail.