OPEN-SOURCE SCRIPT
Double ATR Reversal

// ════════════════════════════════════════════════════════════════════════════
// DOUBLE ATR REVERSAL — Chandelier-style trailing stop + ATR expansion scanner
// ────────────────────────────────────────────────────────────────────────────
// METHOD
// 1. Trailing stop. A ratcheting stop is computed from the rolling extreme
// (highest src_h or lowest src_l over N bars) offset by a multiple of
// Wilder's ATR. The long stop only ratchets up; the short stop only
// ratchets down. When price crosses the opposite side's stop, the
// trend "flips." This is the same construction as the standard
// Chandelier Exit; the "Double ATR" naming refers to the default
// multiplier of 2.0 (faster reversals than the conventional 3.0).
//
// 2. Reversal events. A bull reversal fires on the bar where the trend
// flips from -1 to +1; a bear reversal on +1 to -1. These are
// point-in-time events, distinct from the persistent trend state.
//
// 3. Volatility expansion overlay. Current ATR is compared to a rolling
// SMA of ATR over `expand_len` bars. A separate signal fires when
// current ATR exceeds expand_mult × baseline. This catches news /
// volatility events that are independent of trend direction and is
// the primary addition over a plain trailing-stop indicator.
//
// SOURCE TOGGLE
// `use_close` selects whether the rolling extremes use closing prices
// (smoother, fewer whipsaws) or wicks (more sensitive to spikes). This
// meaningfully changes signal frequency on noisy instruments and is
// exposed as an input rather than hard-coded.
//
// OUTPUTS
// • Trailing stop line, color-coded by trend state
// • Optional bar coloring by trend
// • Bullish / bearish reversal triangles + optional price-annotated labels
// • Yellow background flash + diamond marker on ATR expansion bars
// • Info table: trend, ATR (absolute and as % of price), trail stop,
// multiplier, and expansion state
// • Four alertconditions: bull reversal, bear reversal, any reversal,
// and volatility expansion — suitable for cross-symbol scanning via
// TradingView alert lists
//
// NOT A STRATEGY: orders, slippage, and returns are not modeled.
// ════════════════════════════════════════════════════════════════════════════
// DOUBLE ATR REVERSAL — Chandelier-style trailing stop + ATR expansion scanner
// ────────────────────────────────────────────────────────────────────────────
// METHOD
// 1. Trailing stop. A ratcheting stop is computed from the rolling extreme
// (highest src_h or lowest src_l over N bars) offset by a multiple of
// Wilder's ATR. The long stop only ratchets up; the short stop only
// ratchets down. When price crosses the opposite side's stop, the
// trend "flips." This is the same construction as the standard
// Chandelier Exit; the "Double ATR" naming refers to the default
// multiplier of 2.0 (faster reversals than the conventional 3.0).
//
// 2. Reversal events. A bull reversal fires on the bar where the trend
// flips from -1 to +1; a bear reversal on +1 to -1. These are
// point-in-time events, distinct from the persistent trend state.
//
// 3. Volatility expansion overlay. Current ATR is compared to a rolling
// SMA of ATR over `expand_len` bars. A separate signal fires when
// current ATR exceeds expand_mult × baseline. This catches news /
// volatility events that are independent of trend direction and is
// the primary addition over a plain trailing-stop indicator.
//
// SOURCE TOGGLE
// `use_close` selects whether the rolling extremes use closing prices
// (smoother, fewer whipsaws) or wicks (more sensitive to spikes). This
// meaningfully changes signal frequency on noisy instruments and is
// exposed as an input rather than hard-coded.
//
// OUTPUTS
// • Trailing stop line, color-coded by trend state
// • Optional bar coloring by trend
// • Bullish / bearish reversal triangles + optional price-annotated labels
// • Yellow background flash + diamond marker on ATR expansion bars
// • Info table: trend, ATR (absolute and as % of price), trail stop,
// multiplier, and expansion state
// • Four alertconditions: bull reversal, bear reversal, any reversal,
// and volatility expansion — suitable for cross-symbol scanning via
// TradingView alert lists
//
// NOT A STRATEGY: orders, slippage, and returns are not modeled.
// ════════════════════════════════════════════════════════════════════════════
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.