ATR Volatility Analysis
This script compares short-term vol to longer-term vol to gauge relative volatility, and when short-term vol is elevated, it gives a green light to take trades.
Check out my other free lessons!Source Code
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ZenAndTheArtOfTrading // @version=5 indicator("PineScriptMastery.com") // Get user input int length1 = input.int(title="Short-Term ATR Length", defval=5) int length2 = input.int(title="Long-Term ATR Length", defval=14) float rvolThreshold = input.float(title="RVOL Threshold", defval=1.0) // Get indicator values atr1 = ta.atr(length1) atr2 = ta.atr(length2) // Generate RVOL alert/signal rvolAlert = atr1 > (atr2 * rvolThreshold) volColor = rvolAlert ? color.aqua : color.gray // Draw data to chart plot(atr1, title="Short-Term ATR", style=plot.style_columns, color=volColor) plot(atr2, title="Long-Term ATR", color=color.black) plot(atr2 * rvolThreshold, title="RVOL Threshold", color=color.blue) // Generate alerts alertcondition(rvolAlert, "RVOL Alert", "Momentum has increased on {{ticker}}")