OPEN-SOURCE SCRIPT
Channel Reversion System

WHAT IT DOES
CRS buys weakness at structural support inside an established uptrend, and takes profit when price reverts to the middle of its range. It is deliberately a capital-efficiency system rather than a raw-return system: high hit rate, small symmetric trades, single-digit-to-teens drawdowns, and it sits in cash roughly 80% of the time. Built for liquid index ETFs (QQQ, SPY) on the daily timeframe.
HOW IT WORKS
1) STRUCTURE - a 50-day Donchian channel built on prior-bar highs and lows (no same-bar self-reference) maps the active trading range. The lower quarter of that channel is the accumulation zone.
2) TREND FILTER - entries exist only while price holds above its 200-day SMA. Mean reversion is traded WITH the prevailing trend, never against it; fading downtrends is how reversion accounts die. A close below the SMA while positioned is an immediate exit - trend gone, thesis gone.
3) ENTRY - close enters the lower quarter of the channel while the trend filter holds. Location plus regime, no prediction.
4) EXITS - profit target at the channel midline (the reversion to the middle of the range is the statistically reliable move); hard stop one ATR(14) below the channel floor (if the range itself fails, the location thesis is falsified); regime exit on the 200-SMA break.
BACKTEST PROPERTIES (fully disclosed)
0.05% commission per side, 1 tick slippage, fills on close, $10,000 initial capital. QQQ daily March 1999 - August 2026 (a 27-year window that includes the dot-com collapse and the 2008 crisis): +104% net, profit factor 2.28, 64% winners, 58 trades, max drawdown 15.2%. Cross-symbol with parameters frozen: SPY +67%, profit factor 1.80, 62% winners, max drawdown 8.5%. Stated plainly: CRS does NOT beat buy-and-hold on raw return - a system that is long roughly 20% of the time cannot outrun a secular bull market. What transfers across symbols untouched is the character: high hit rate, small symmetric win/loss sizes, small drawdown.
WHAT WAS TESTED AND REJECTED
A chandelier-trail "let winners ride" exit was tested and REJECTED with numbers: same net return, profit factor down from 2.28 to 1.79, win rate 64% to 47%, drawdown up from 15% to 19%. In a mean-reversion system the target IS the edge. A 3x leveraged wrapper (TQQQ) was also tested and REJECTED: profit factor collapsed to 1.43 and max drawdown tripled to 43% - leverage triples the noise around the structural stop.
INPUTS
Channel length (50), entry zone as % of channel (25), trend SMA length (200), ATR length (14), stop distance in ATR below the channel floor (1.0).
LIMITATIONS
In-sample, single-history backtests - upper bounds on expectancy, not forecasts. The QQQ/SPY pair shares one market era; genuine robustness claims need non-US indices and bear-heavy subperiods. Validate on your own symbols and windows before relying on it. Not financial advice.
CRS buys weakness at structural support inside an established uptrend, and takes profit when price reverts to the middle of its range. It is deliberately a capital-efficiency system rather than a raw-return system: high hit rate, small symmetric trades, single-digit-to-teens drawdowns, and it sits in cash roughly 80% of the time. Built for liquid index ETFs (QQQ, SPY) on the daily timeframe.
HOW IT WORKS
1) STRUCTURE - a 50-day Donchian channel built on prior-bar highs and lows (no same-bar self-reference) maps the active trading range. The lower quarter of that channel is the accumulation zone.
2) TREND FILTER - entries exist only while price holds above its 200-day SMA. Mean reversion is traded WITH the prevailing trend, never against it; fading downtrends is how reversion accounts die. A close below the SMA while positioned is an immediate exit - trend gone, thesis gone.
3) ENTRY - close enters the lower quarter of the channel while the trend filter holds. Location plus regime, no prediction.
4) EXITS - profit target at the channel midline (the reversion to the middle of the range is the statistically reliable move); hard stop one ATR(14) below the channel floor (if the range itself fails, the location thesis is falsified); regime exit on the 200-SMA break.
BACKTEST PROPERTIES (fully disclosed)
0.05% commission per side, 1 tick slippage, fills on close, $10,000 initial capital. QQQ daily March 1999 - August 2026 (a 27-year window that includes the dot-com collapse and the 2008 crisis): +104% net, profit factor 2.28, 64% winners, 58 trades, max drawdown 15.2%. Cross-symbol with parameters frozen: SPY +67%, profit factor 1.80, 62% winners, max drawdown 8.5%. Stated plainly: CRS does NOT beat buy-and-hold on raw return - a system that is long roughly 20% of the time cannot outrun a secular bull market. What transfers across symbols untouched is the character: high hit rate, small symmetric win/loss sizes, small drawdown.
WHAT WAS TESTED AND REJECTED
A chandelier-trail "let winners ride" exit was tested and REJECTED with numbers: same net return, profit factor down from 2.28 to 1.79, win rate 64% to 47%, drawdown up from 15% to 19%. In a mean-reversion system the target IS the edge. A 3x leveraged wrapper (TQQQ) was also tested and REJECTED: profit factor collapsed to 1.43 and max drawdown tripled to 43% - leverage triples the noise around the structural stop.
INPUTS
Channel length (50), entry zone as % of channel (25), trend SMA length (200), ATR length (14), stop distance in ATR below the channel floor (1.0).
LIMITATIONS
In-sample, single-history backtests - upper bounds on expectancy, not forecasts. The QQQ/SPY pair shares one market era; genuine robustness claims need non-US indices and bear-heavy subperiods. Validate on your own symbols and windows before relying on it. Not financial advice.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
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.