OPEN-SOURCE SCRIPT
ATR EMA Multiple

A TradingView (Pine Script v6) oscillator that measures how far price has stretched from its moving average, expressed in units of ATR (Average True Range).
Instead of asking "how many dollars/points is price away from its average?", this indicator asks "how many typical bars of volatility is price away from its average?" That makes the reading comparable across different symbols, timeframes, and volatility regimes.
WHAT IT PLOTS
The main line (white) is the oscillator:
oscillator = (close - EMA(close, maPeriod)) / ATR(atrPeriod)
A red line above and a green line below act as reference bands. How those two
bands are placed is controlled by the Line Mode setting (see below).
Typical use: when the oscillator pushes into or beyond the red band, price is
unusually extended to the upside; the green band marks unusual extension to the
downside. How you act on that (mean-reversion, breakout confirmation, etc.) is
up to your strategy.
SETTINGS
ATR and EMA Settings
ATR Period (default 14)
Lookback for the ATR used as the volatility unit.
Moving Average Period (default 21)
Lookback for the EMA that price is measured against.
Reference Lines
Line Mode (default Manual)
Chooses how the red/green bands are positioned:
"Manual" or "Std Deviations".
Manual mode
You set the band levels directly, in ATR units.
Manual: red line ATR level (default 3)
Red band drawn at this fixed oscillator value (e.g. +3 ATRs).
Manual: green line ATR level (default -3)
Green band drawn at this fixed oscillator value (e.g. -3 ATRs).
The bands are flat, fixed horizontal lines. Good when you want a constant, opinionated threshold.
Std Deviations mode
The bands adapt to the symbol's recent behaviour. You specify how many standard deviations from 0 each band should sit, and the script measures the actual standard deviation from the data.
Std Dev: red line std devs above 0 (default 2)
Red band at this many standard deviations above 0.
Std Dev: green line std devs below 0 (default 2)
Green band at this many standard deviations below 0.
Std Dev: lookback length (bars) (default 200)
How many recent bars are sampled to measure the standard deviation.
The bands move over time as volatility behaviour changes, automatically tightening in calm conditions and widening in stretched ones.
HOW "STD DEVIATIONS" MODE IS CALCULATED
This is worth understanding before you rely on it, because it is a deliberate, slightly non-standard choice.
The standard deviation is measured separately for the positive and negative sides of the oscillator, and anchored at 0 (not at each side's own average):
sigma_positive = sqrt( mean( oscillator^2 over bars where oscillator > 0 ) )
sigma_negative = sqrt( mean( oscillator^2 over bars where oscillator < 0 ) )
red band = (+ std devs above) x sigma_positive
green band = (- std devs below) x sigma_negative
Two consequences of this design:
On a freshly loaded chart the bands stay blank until the lookback window contains at least one positive and one negative reading.
READING THE COLOURS
NOTES & LIMITATIONS
LICENSE
Open source -- published for the TradingView community. Attribution appreciated.
Instead of asking "how many dollars/points is price away from its average?", this indicator asks "how many typical bars of volatility is price away from its average?" That makes the reading comparable across different symbols, timeframes, and volatility regimes.
WHAT IT PLOTS
The main line (white) is the oscillator:
oscillator = (close - EMA(close, maPeriod)) / ATR(atrPeriod)
- A value of +2 means price is currently 2 ATRs above its EMA.
- A value of -1.5 means price is 1.5 ATRs below its EMA.
- The yellow line at 0 marks price sitting exactly on its EMA.
A red line above and a green line below act as reference bands. How those two
bands are placed is controlled by the Line Mode setting (see below).
Typical use: when the oscillator pushes into or beyond the red band, price is
unusually extended to the upside; the green band marks unusual extension to the
downside. How you act on that (mean-reversion, breakout confirmation, etc.) is
up to your strategy.
SETTINGS
ATR and EMA Settings
ATR Period (default 14)
Lookback for the ATR used as the volatility unit.
Moving Average Period (default 21)
Lookback for the EMA that price is measured against.
Reference Lines
Line Mode (default Manual)
Chooses how the red/green bands are positioned:
"Manual" or "Std Deviations".
Manual mode
You set the band levels directly, in ATR units.
Manual: red line ATR level (default 3)
Red band drawn at this fixed oscillator value (e.g. +3 ATRs).
Manual: green line ATR level (default -3)
Green band drawn at this fixed oscillator value (e.g. -3 ATRs).
The bands are flat, fixed horizontal lines. Good when you want a constant, opinionated threshold.
Std Deviations mode
The bands adapt to the symbol's recent behaviour. You specify how many standard deviations from 0 each band should sit, and the script measures the actual standard deviation from the data.
Std Dev: red line std devs above 0 (default 2)
Red band at this many standard deviations above 0.
Std Dev: green line std devs below 0 (default 2)
Green band at this many standard deviations below 0.
Std Dev: lookback length (bars) (default 200)
How many recent bars are sampled to measure the standard deviation.
The bands move over time as volatility behaviour changes, automatically tightening in calm conditions and widening in stretched ones.
HOW "STD DEVIATIONS" MODE IS CALCULATED
This is worth understanding before you rely on it, because it is a deliberate, slightly non-standard choice.
The standard deviation is measured separately for the positive and negative sides of the oscillator, and anchored at 0 (not at each side's own average):
sigma_positive = sqrt( mean( oscillator^2 over bars where oscillator > 0 ) )
sigma_negative = sqrt( mean( oscillator^2 over bars where oscillator < 0 ) )
red band = (+ std devs above) x sigma_positive
green band = (- std devs below) x sigma_negative
Two consequences of this design:
- Anchored at 0, not at the mean. Because the bands are described as "N standard deviations above 0 / below 0", the spread is measured as the root-mean-square of values around 0 -- not the textbook standard deviation around the sample mean. This keeps 0 (price = EMA) as the true center of the scale.
- Asymmetric by design. The upside and downside are measured independently, so a market that stretches further on rallies than on sell-offs (or vice versa) will get an asymmetric pair of bands that reflects that.
On a freshly loaded chart the bands stay blank until the lookback window contains at least one positive and one negative reading.
READING THE COLOURS
- Oscillator White Price distance from EMA, in ATR units.
- Upper band Red Upside extension threshold.
- Lower band Green Downside extension threshold.
- Zero line Yellow Price equals its EMA.
NOTES & LIMITATIONS
- The indicator is not a standalone trading system -- it's a normalization/context tool. Combine it with your own entry/exit logic and risk management.
- Readings are only comparable when the ATR Period and Moving Average Period are held constant.
- The red/green reference bands are drawn as dashed lines to distinguish them from the solid white oscillator.
- On instruments with periods of zero volatility (ATR = 0), the oscillator value is undefined for those bars.
LICENSE
Open source -- published for the TradingView community. Attribution appreciated.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Time Trades is a data service that combines machine learning and Gann techniques to provide time centric forecasts. These are intended to be combined with your existing price analysis to provide a trading edge.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Time Trades is a data service that combines machine learning and Gann techniques to provide time centric forecasts. These are intended to be combined with your existing price analysis to provide a trading edge.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.