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.
// ════════════════════════════════════════════════════════════════════════════
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.