OPEN-SOURCE SCRIPT

Double ATR Reversal

390
// ════════════════════════════════════════════════════════════════════════════
// 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.
// ════════════════════════════════════════════════════════════════════════════

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.