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.
// ════════════════════════════════════════════════════════════════════════════
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.