OPEN-SOURCE SCRIPT
Aggiornato

Asymmetric Traffic Light - Regime Filter

275
Overview
The Asymmetric Traffic Light is a trend regime classification system that categorizes market conditions into four distinct states: Green (bullish), Yellow (neutral), Orange (transition), and Red (bearish). Unlike simple traffic light indicators, this version includes an asymmetric transition rule that prevents the market from jumping directly from Red to Green, reducing false signals during volatile recoveries.

How It Works

Regime Definitions

RED (Bearish) - Price is below both the 200 SMA and 50 SMA. This represents a confirmed downtrend where both short and long-term momentum are negative. Risk should be minimized.

GREEN (Bullish) - Three conditions must be met simultaneously:
  • Price is above the 200 SMA
  • The 200 SMA slope is positive (rising over the lookback period)
  • The 50 SMA is above its value from 5 bars ago (showing upward momentum)

This triple confirmation ensures you only get Green during genuine bullish conditions, not just price spikes above the moving average.

YELLOW (Neutral) - Any condition that is neither Red nor Green. This includes situations where price is above one MA but below the other, or when the slope conditions are not met.

ORANGE (Transition Quarantine) - This is the key innovation. When price exits Red (transitions to non-Red), the indicator enters a mandatory 4-bar quarantine period. During this time, even if Green conditions are technically met, the indicator displays Orange instead.

Why the Orange Quarantine Matters

Markets often experience sharp bear market rallies that quickly fail. Without the quarantine:
  • Day 1: Red (price below both MAs)
  • Day 2: Sharp rally, price spikes above both MAs → Would show Green
  • Day 3: Rally fails, back to Red


With the quarantine:
  • Day 1: Red
  • Day 2: Sharp rally → Orange (quarantine bar 1 of 4)
  • Day 3: Rally fails → Back to Red (quarantine resets)


The asymmetry means you need sustained strength to reach Green, but you can fall into Red immediately. This matches the reality that markets tend to fall faster than they rise.

What Makes This Different
Most traffic light indicators use simple threshold crossings that generate excessive signals during choppy conditions. The asymmetric transition rule acknowledges that exiting a bearish regime requires more confirmation than entering one. This design philosophy prioritizes avoiding false bullish signals over capturing every rally.

Settings Guide

Moving Average Settings
  • [code]Long SMA Length[/code] - Primary trend filter. Default 200 matches institutional trend reference. Range: 50-500.
  • [code]Short SMA Length[/code] - Secondary trend filter. Default 50 for intermediate trend. Range: 10-100.
  • [code]Slope Lookback[/code] - Period to measure SMA200 direction. Default 20 bars. Shorter = more responsive, longer = smoother.
  • [code]Short MA Momentum Lookback[/code] - Bars to compare for SMA50 upward momentum. Default 5.


Transition Settings
  • [code]Orange Quarantine Bars[/code] - Mandatory waiting period after exiting Red. Default 4 bars. Increase for more conservative signals.


Visual Settings
  • Color customization for each regime state
  • Toggle background coloring on/off
  • Toggle regime change labels


How to Use
  • Add the indicator to your chart (works best on daily timeframe for position trading)
  • GREEN: Full position size, bullish bias
  • YELLOW: Reduced exposure, no directional bias
  • ORANGE: Remain cautious, do not increase bullish exposure yet
  • RED: Defensive positioning, avoid new longs


The indicator outputs numeric regime values (0-3) and boolean flags that can be referenced by other scripts for systematic strategy development.

Alerts
  • Green Regime - Triggered when transitioning into confirmed bullish conditions
  • Red Regime - Triggered when entering bearish conditions
  • Orange Transition - Triggered when exiting Red into quarantine period
  • Yellow Regime - Triggered when entering neutral conditions
  • Any Regime Change - Triggered on any state transition


Best Practices
  • Use on daily charts for swing/position trading timeframes
  • Combine with your entry timing indicators - this is a filter, not a signal generator
  • Consider increasing quarantine bars during high-volatility periods
  • The Orange state is particularly valuable after sharp selloffs to avoid bear trap rallies


Limitations
  • Lagging indicator - moving averages by nature respond to past price action
  • The quarantine period may cause you to miss the first few bars of legitimate rallies
  • Optimized for daily timeframes; lower timeframes may generate excessive state changes
  • Does not account for volume, volatility, or external factors


Disclaimer
This indicator is for educational and informational purposes only. It does not constitute financial advice.
  • Past performance does not guarantee future results
  • Always conduct your own research before making trading decisions
  • Consider your risk tolerance and investment objectives
  • This is a filter tool, not a complete trading system
Note di rilascio
// ══════════════════════════════════════════════════════════════════════════════
// ─── Version ────────────────────────────────────────────────────────────────
// ══════════════════════════════════════════════════════════════════════════════
// v1.0 - New indicator
// v1.1 - Updated screenshot for a cleaner screenshot without other indicators

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.