OPEN-SOURCE SCRIPT
Adaptive Trend Navigator [ATH Filter & Risk Engine]

Description:
This strategy implements a systematic Trend Following approach designed to capture major moves while actively protecting capital during severe bear markets. It combines a classic Moving Average "Fan" logic with two advanced risk management layers: a 4-Stage Dynamic Stop Loss and a macro-economic "Circuit Breaker" filter.
Core Concepts:
1. Trend Identification (Entry Logic) The script uses a cascade of Simple Moving Averages (SMA 25, 50, 100, 200) to identify the maturity of a trend.
Entries are triggered by specific crossovers (e.g., SMA 25 crossing SMA 50) or by breaking above the previous trade's high ("High-Water Mark" Re-Entry).
2. The "Circuit Breaker" (Crash Protection) To prevent trading during historical market collapses (like 2000 or 2008), the strategy monitors the Nasdaq 100 (QQQ) as a global benchmark:
Normal Regime: If the market is within 20% of its All-Time High, the strategy operates normally.
Crisis Regime: If the QQQ falls more than 20% from its ATH, the "Circuit Breaker" activates (Visualized by a Red Background).
Recovery Rule: In a Crisis Regime, new long positions are blocked unless the QQQ reclaims its SMA 200. This filters out "bull traps" in secular bear markets.
3. 4-Stage Risk Engine (Exit Logic) Once in a trade, the risk management adapts to the position's performance:
Stage 1: Fixed initial Stop Loss (default 10%) for breathing room.
Stage 2: Moves to Break-Even area once the price rises 12%.
Stage 3: Tightens to a trailing stop (8%) after 25% profit.
Stage 4: Maximizes gains with a tight trailing stop (5%) during parabolic moves (>40% profit).
Visual Guide:
SMAs: 25/50/100/200 period lines for trend visualization.
Red Background: Indicates the "Crisis Regime" where trading is halted due to broad market weakness.
Blue Background: Indicates a "Recovery Phase" (Crisis is active, but market is above SMA 200).
Red Line: Shows the dynamic Stop Loss level for active positions.
Settings: All parameters (SMA lengths, Drawdown threshold, Risk Stages) are fully customizable. The QQQ benchmark ticker can also be changed to SPY or other indices depending on the asset class traded.
This strategy implements a systematic Trend Following approach designed to capture major moves while actively protecting capital during severe bear markets. It combines a classic Moving Average "Fan" logic with two advanced risk management layers: a 4-Stage Dynamic Stop Loss and a macro-economic "Circuit Breaker" filter.
Core Concepts:
1. Trend Identification (Entry Logic) The script uses a cascade of Simple Moving Averages (SMA 25, 50, 100, 200) to identify the maturity of a trend.
Entries are triggered by specific crossovers (e.g., SMA 25 crossing SMA 50) or by breaking above the previous trade's high ("High-Water Mark" Re-Entry).
2. The "Circuit Breaker" (Crash Protection) To prevent trading during historical market collapses (like 2000 or 2008), the strategy monitors the Nasdaq 100 (QQQ) as a global benchmark:
Normal Regime: If the market is within 20% of its All-Time High, the strategy operates normally.
Crisis Regime: If the QQQ falls more than 20% from its ATH, the "Circuit Breaker" activates (Visualized by a Red Background).
Recovery Rule: In a Crisis Regime, new long positions are blocked unless the QQQ reclaims its SMA 200. This filters out "bull traps" in secular bear markets.
3. 4-Stage Risk Engine (Exit Logic) Once in a trade, the risk management adapts to the position's performance:
Stage 1: Fixed initial Stop Loss (default 10%) for breathing room.
Stage 2: Moves to Break-Even area once the price rises 12%.
Stage 3: Tightens to a trailing stop (8%) after 25% profit.
Stage 4: Maximizes gains with a tight trailing stop (5%) during parabolic moves (>40% profit).
Visual Guide:
SMAs: 25/50/100/200 period lines for trend visualization.
Red Background: Indicates the "Crisis Regime" where trading is halted due to broad market weakness.
Blue Background: Indicates a "Recovery Phase" (Crisis is active, but market is above SMA 200).
Red Line: Shows the dynamic Stop Loss level for active positions.
Settings: All parameters (SMA lengths, Drawdown threshold, Risk Stages) are fully customizable. The QQQ benchmark ticker can also be changed to SPY or other indices depending on the asset class traded.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.