PROTECTED SOURCE SCRIPT
Dual ATR Trailing Stop - Buy/Sell Signals - MCH

๐ฏ DUAL ATR TRAILING STOP - ADVANCED BUY/SELL SIGNAL SYSTEM
A sophisticated trend-following indicator that combines dual ATR trailing stops with intelligent 4-state market condition analysis for precise entry and exit signals.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โก WHAT MAKES THIS INDICATOR UNIQUE
This indicator goes beyond traditional ATR implementations by combining:
- Dual ATR trailing stop system with crossover signal generation
- 4-state market condition classifier (not just bull/bear)
- Real-time P&L tracking from signal entries
- Advanced candle analysis (examining highs, lows, and close relative to ATR levels)
- Dynamic trend confirmation using barssince() methodology
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ CORE METHODOLOGY EXPLAINED
1๏ธโฃ DUAL ATR TRAILING STOP SYSTEM
The indicator calculates two independent ATR-based trailing stops:
FAST ATR TRAIL:
- Default: 5-period ATR with 0.5 multiplier
- Reacts quickly to price movements
- Captures early momentum shifts
- Calculation: Fast Stop Loss = 0.5 ร ATR(5)
SLOW ATR TRAIL:
- Default: 10-period ATR with 3.0 multiplier
- Provides trend confirmation
- Filters false signals in choppy markets
- Calculation: Slow Stop Loss = 3.0 ร ATR(10)
SIGNAL GENERATION LOGIC:
- ๐ข BUY Signal: Generated when Fast ATR Trail crosses ABOVE Slow ATR Trail
- ๐ด SELL Signal: Generated when Fast ATR Trail crosses BELOW Slow ATR Trail
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2๏ธโฃ FOUR-STATE MARKET CONDITION CLASSIFIER
Unlike basic ATR indicators that only show bull/bear states, this system identifies 4 DISTINCT MARKET CONDITIONS by analyzing candle structure relative to both ATR levels:
๐ข STRONG BULL (Green Candles):
- Condition: Fast Trail > Slow Trail AND Close > Slow Trail AND Low > Slow Trail
- Meaning: Strong uptrend with no pullbacks below Slow ATR
- Trading implication: High confidence bullish momentum
๐ต BULL WITH PULLBACK (Blue Candles):
- Condition: Fast Trail > Slow Trail AND Close > Slow Trail BUT Low < Slow Trail
- Meaning: Uptrend but with intrabar pullbacks
- Trading implication: Bullish but watch for potential reversal
๐ด STRONG BEAR (Red Candles):
- Condition: Slow Trail > Fast Trail AND Close < Slow Trail AND High < Slow Trail
- Meaning: Strong downtrend with no bounces above Slow ATR
- Trading implication: High confidence bearish momentum
๐ก BEAR WITH BOUNCE (Yellow Candles):
- Condition: Slow Trail > Fast Trail AND Close < Slow Trail BUT High > Slow Trail
- Meaning: Downtrend but with intrabar bounces
- Trading implication: Bearish but watch for potential reversal
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
3๏ธโฃ DYNAMIC TRAIL CALCULATION
The ATR trailing stops use adaptive logic that adjusts to market conditions:
IF price > previous trail AND previous price > previous trail:
New Trail = MAX(previous trail, current price - stop loss)
ELSE IF price < previous trail AND previous price < previous trail:
New Trail = MIN(previous trail, current price + stop loss)
ELSE IF trend reverses:
Recalculate trail from current price level
This ensures the stops trail price appropriately while preventing premature exits during normal volatility.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
4๏ธโฃ TREND DIRECTION CONFIRMATION
The indicator uses a unique barssince() comparison method:
- BULLISH TREND: bars since Strong Bull < bars since Strong Bear
- BEARISH TREND: bars since Strong Bear < bars since Strong Bull
This provides an objective measure of which market state occurred more recently, helping filter signals.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ VISUAL FEATURES
- Color-Coded Candles: Green/Blue/Red/Yellow based on 4 market states
- ATR Level Lines: Blue (Fast Trail), Green/Red (Slow Trail depending on trend)
- Fill Zones: Shaded area between Fast and Slow ATR (Green fill = bullish, Red fill = bearish)
- Signal Shapes: Green triangles (BUY), Red triangles (SELL)
- Real-Time Info Panel showing:
- Current position (LONG/SHORT/NONE)
- Entry price
- Current price
- P&L percentage from last signal
- Market condition state
- Fast & Slow ATR values
- Overall trend direction
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ALERT SYSTEM
Built-in alert conditions for:
- ATR BUY: Triggers when Fast crosses above Slow
- ATR SELL: Triggers when Fast crosses below Slow
- Strong Bull: Triggers when entering strong bullish condition
- Strong Bear: Triggers when entering strong bearish condition
Alert messages include: Price, Fast ATR value, Slow ATR value
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ CUSTOMIZABLE PARAMETERS
ATR SETTINGS:
- Fast ATR Period: 1-50 (default: 5)
- Fast ATR Multiplier: 0.1-5.0 (default: 0.5)
- Slow ATR Period: 1-50 (default: 10)
- Slow ATR Multiplier: 0.1-10.0 (default: 3.0)
VISUAL SETTINGS:
- Paint color on chart: Enable/disable candle coloring
- Show ATR levels: Toggle ATR line visibility
ALERT SETTINGS:
- Enable Alerts: Master switch for all alert conditions
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก HOW TO USE
FOR TREND FOLLOWING:
1. Wait for BUY signal (green triangle) when Fast crosses above Slow
2. Confirm with STRONG BULL market condition (green candles)
3. Hold position until SELL signal appears
4. Monitor P&L% in info panel
FOR RISK MANAGEMENT:
- Use Slow ATR line as dynamic stop loss level
- Exit if market changes to opposite strong condition
- Be cautious in BLUE/YELLOW states (pullback zones)
FOR SCALPING:
- Use lower timeframes (5m, 15m)
- Adjust Fast ATR to more sensitive settings (period 3, multiplier 0.3)
- Take profits at opposite color candles
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ BEST MARKET CONDITIONS
WORKS BEST ON:
- Trending markets with clear directional moves
- Forex pairs: EUR/USD, GBP/USD, USD/JPY
- Crypto: BTC/USDT, ETH/USDT, major altcoins
- Stock indices: S&P 500, NASDAQ, DAX
- Commodities: Gold, Silver, Oil
RECOMMENDED TIMEFRAMES:
- Swing Trading: 4H, Daily
- Day Trading: 15m, 1H
- Scalping: 5m, 15m (with adjusted parameters)
LESS EFFECTIVE IN:
- Ranging/choppy markets (generates false signals)
- Very low liquidity instruments
- During major news events (extreme volatility)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ RISK DISCLAIMER
This indicator is a technical analysis tool and should not be used as the sole basis for trading decisions. Always use proper risk management, combine with other analysis methods, and never risk more than you can afford to lose. Past performance does not guarantee future results.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ SUPPORT & UPDATES
For questions, suggestions, or issues, please comment below or send a private message. Regular updates and improvements based on user feedback.
Version: 1.0 | Pine Script v6 | Works on all TradingView plans
A sophisticated trend-following indicator that combines dual ATR trailing stops with intelligent 4-state market condition analysis for precise entry and exit signals.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โก WHAT MAKES THIS INDICATOR UNIQUE
This indicator goes beyond traditional ATR implementations by combining:
- Dual ATR trailing stop system with crossover signal generation
- 4-state market condition classifier (not just bull/bear)
- Real-time P&L tracking from signal entries
- Advanced candle analysis (examining highs, lows, and close relative to ATR levels)
- Dynamic trend confirmation using barssince() methodology
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ CORE METHODOLOGY EXPLAINED
1๏ธโฃ DUAL ATR TRAILING STOP SYSTEM
The indicator calculates two independent ATR-based trailing stops:
FAST ATR TRAIL:
- Default: 5-period ATR with 0.5 multiplier
- Reacts quickly to price movements
- Captures early momentum shifts
- Calculation: Fast Stop Loss = 0.5 ร ATR(5)
SLOW ATR TRAIL:
- Default: 10-period ATR with 3.0 multiplier
- Provides trend confirmation
- Filters false signals in choppy markets
- Calculation: Slow Stop Loss = 3.0 ร ATR(10)
SIGNAL GENERATION LOGIC:
- ๐ข BUY Signal: Generated when Fast ATR Trail crosses ABOVE Slow ATR Trail
- ๐ด SELL Signal: Generated when Fast ATR Trail crosses BELOW Slow ATR Trail
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2๏ธโฃ FOUR-STATE MARKET CONDITION CLASSIFIER
Unlike basic ATR indicators that only show bull/bear states, this system identifies 4 DISTINCT MARKET CONDITIONS by analyzing candle structure relative to both ATR levels:
๐ข STRONG BULL (Green Candles):
- Condition: Fast Trail > Slow Trail AND Close > Slow Trail AND Low > Slow Trail
- Meaning: Strong uptrend with no pullbacks below Slow ATR
- Trading implication: High confidence bullish momentum
๐ต BULL WITH PULLBACK (Blue Candles):
- Condition: Fast Trail > Slow Trail AND Close > Slow Trail BUT Low < Slow Trail
- Meaning: Uptrend but with intrabar pullbacks
- Trading implication: Bullish but watch for potential reversal
๐ด STRONG BEAR (Red Candles):
- Condition: Slow Trail > Fast Trail AND Close < Slow Trail AND High < Slow Trail
- Meaning: Strong downtrend with no bounces above Slow ATR
- Trading implication: High confidence bearish momentum
๐ก BEAR WITH BOUNCE (Yellow Candles):
- Condition: Slow Trail > Fast Trail AND Close < Slow Trail BUT High > Slow Trail
- Meaning: Downtrend but with intrabar bounces
- Trading implication: Bearish but watch for potential reversal
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
3๏ธโฃ DYNAMIC TRAIL CALCULATION
The ATR trailing stops use adaptive logic that adjusts to market conditions:
IF price > previous trail AND previous price > previous trail:
New Trail = MAX(previous trail, current price - stop loss)
ELSE IF price < previous trail AND previous price < previous trail:
New Trail = MIN(previous trail, current price + stop loss)
ELSE IF trend reverses:
Recalculate trail from current price level
This ensures the stops trail price appropriately while preventing premature exits during normal volatility.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
4๏ธโฃ TREND DIRECTION CONFIRMATION
The indicator uses a unique barssince() comparison method:
- BULLISH TREND: bars since Strong Bull < bars since Strong Bear
- BEARISH TREND: bars since Strong Bear < bars since Strong Bull
This provides an objective measure of which market state occurred more recently, helping filter signals.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ VISUAL FEATURES
- Color-Coded Candles: Green/Blue/Red/Yellow based on 4 market states
- ATR Level Lines: Blue (Fast Trail), Green/Red (Slow Trail depending on trend)
- Fill Zones: Shaded area between Fast and Slow ATR (Green fill = bullish, Red fill = bearish)
- Signal Shapes: Green triangles (BUY), Red triangles (SELL)
- Real-Time Info Panel showing:
- Current position (LONG/SHORT/NONE)
- Entry price
- Current price
- P&L percentage from last signal
- Market condition state
- Fast & Slow ATR values
- Overall trend direction
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ALERT SYSTEM
Built-in alert conditions for:
- ATR BUY: Triggers when Fast crosses above Slow
- ATR SELL: Triggers when Fast crosses below Slow
- Strong Bull: Triggers when entering strong bullish condition
- Strong Bear: Triggers when entering strong bearish condition
Alert messages include: Price, Fast ATR value, Slow ATR value
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ CUSTOMIZABLE PARAMETERS
ATR SETTINGS:
- Fast ATR Period: 1-50 (default: 5)
- Fast ATR Multiplier: 0.1-5.0 (default: 0.5)
- Slow ATR Period: 1-50 (default: 10)
- Slow ATR Multiplier: 0.1-10.0 (default: 3.0)
VISUAL SETTINGS:
- Paint color on chart: Enable/disable candle coloring
- Show ATR levels: Toggle ATR line visibility
ALERT SETTINGS:
- Enable Alerts: Master switch for all alert conditions
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก HOW TO USE
FOR TREND FOLLOWING:
1. Wait for BUY signal (green triangle) when Fast crosses above Slow
2. Confirm with STRONG BULL market condition (green candles)
3. Hold position until SELL signal appears
4. Monitor P&L% in info panel
FOR RISK MANAGEMENT:
- Use Slow ATR line as dynamic stop loss level
- Exit if market changes to opposite strong condition
- Be cautious in BLUE/YELLOW states (pullback zones)
FOR SCALPING:
- Use lower timeframes (5m, 15m)
- Adjust Fast ATR to more sensitive settings (period 3, multiplier 0.3)
- Take profits at opposite color candles
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ BEST MARKET CONDITIONS
WORKS BEST ON:
- Trending markets with clear directional moves
- Forex pairs: EUR/USD, GBP/USD, USD/JPY
- Crypto: BTC/USDT, ETH/USDT, major altcoins
- Stock indices: S&P 500, NASDAQ, DAX
- Commodities: Gold, Silver, Oil
RECOMMENDED TIMEFRAMES:
- Swing Trading: 4H, Daily
- Day Trading: 15m, 1H
- Scalping: 5m, 15m (with adjusted parameters)
LESS EFFECTIVE IN:
- Ranging/choppy markets (generates false signals)
- Very low liquidity instruments
- During major news events (extreme volatility)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ RISK DISCLAIMER
This indicator is a technical analysis tool and should not be used as the sole basis for trading decisions. Always use proper risk management, combine with other analysis methods, and never risk more than you can afford to lose. Past performance does not guarantee future results.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ SUPPORT & UPDATES
For questions, suggestions, or issues, please comment below or send a private message. Regular updates and improvements based on user feedback.
Version: 1.0 | Pine Script v6 | Works on all TradingView plans
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations โ learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations โ learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.