ATR Momentum Pro

This indicator visualizes the **momentum of volatility** by calculating the difference between the current ATR (Average True Range) and its moving average. It helps detect periods when market volatility is accelerating or decelerating.
---
### ⚙️ **1. User Inputs**
```pinescript
atr_length = input.int(14, "ATR Period", minval=1, maxval=100)
ma_length = input.int(20, "MA Period", minval=1, maxval=50)
ma_type = input.string("SMA", "MA Type", options=["SMA", "EMA", "RMA", "WMA"])
```
* `atr_length`: Number of periods used to calculate ATR (default is 14).
* `ma_length`: Number of periods for smoothing the ATR.
* `ma_type`: Type of Moving Average to use for smoothing (SMA, EMA, RMA, or WMA).
---
### 📈 **2. Calculations**
```pinescript
atr = ta.atr(atr_length)
```
* Calculates the standard **ATR**, which measures market volatility using high, low, and close prices.
```pinescript
ma_value = switch ma_type
"SMA" => ta.sma(atr, ma_length)
"EMA" => ta.ema(atr, ma_length)
"RMA" => ta.rma(atr, ma_length)
"WMA" => ta.wma(atr, ma_length)
```
* Applies the selected Moving Average to the ATR to smooth it.
```pinescript
oscillator = atr - ma_value
```
* Calculates the **ATR Momentum Oscillator**:
* Positive values: volatility is increasing.
* Negative values: volatility is decreasing.
---
### 📊 **3. Oscillator Plot**
```pinescript
plot(oscillator, "ATR Momentum", color=color.new(color.blue, 0), style=plot.style_histogram)
```
* Plots the oscillator as a **blue histogram** in a separate pane below the chart.
---
### 🏷️ **4. Informational Label**
```pinescript
var label lbl = label.new(bar_index, na, "", style=label.style_label_center)
if barstate.islast
label.set_xy(lbl, bar_index, ta.highest(high, 10)[1])
label.set_text(lbl,
"ATR: " + str.tostring(atr, "#.##") +
"\nMA(" + str.tostring(ma_length) + "): " + str.tostring(ma_value, "#.##") +
"\nMomentum: " + str.tostring(oscillator, "#.##"))
label.set_color(lbl, oscillator > 0 ? color.green : color.red)
```
* Creates a **single label** that updates only on the **latest bar**.
* The label shows:
* Current ATR
* ATR moving average
* Momentum (difference between the two)
* Label color:
* **Green** if momentum > 0
* **Red** if momentum < 0
* The label is positioned just above the price (highest high of the last 10 bars, offset by 1 bar).
---
### ✅ **Use Case**
This indicator is useful for:
* Spotting increases or decreases in market volatility
* Confirming breakout strength
* Filtering trades based on volatility momentum
---
Would you like me to add **buy/sell signals** when the oscillator crosses above or below zero?
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.
Declinazione di responsabilità
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.