OPEN-SOURCE SCRIPT
Combined ATPC & MACD Divergence

Trend Optimizer + Divergence Finder in One Unified Tool
🔍 Overview:
This powerful dual-system indicator merges two proven analytical engines:
✅ The Algorganic Typical Price Channel (ATPC) — a custom trend oscillator that highlights mean-reversion and directional bias.
✅ A refined MACD system with divergence detection, enhanced with an adjusted Donchian midline for real-time trend strength filtering.
Together, they provide a high-confidence, multi-signal system ideal for swing trading, scalping, or confirming reversals with context.
⚙️ Core Components & Logic
🧠 1. ATPC Engine (Trend Commodity Index)
A momentum and volatility-normalized oscillator based on the typical price (H+L+C)/3:
TrendCI Line (Blue) – Main trend signal based on smoothed CCI logic.
TrendLine2 (Orange) – A slower smoothing of TrendCI for crossovers.
Key Zones (customizable):
🔴 Ultra Overbought: +73
🟣 Overbought: +58
🟣 Oversold: -58
🔴 Ultra Oversold: -73
Trade Logic:
✅ Buy Signal: TrendCI crosses above TrendLine2 while in oversold zone
❌ Sell Signal: TrendCI crosses below TrendLine2 while in overbought zone
Additional visual feedback:
Histogram Bars show strength and direction of momentum shift
Green/Red Circles highlight potential long/short setups
📉 2. MACD System + Divergence Finder
Classic MACD enhanced with a Donchian Midline overlay to filter trend bias.
🔷 MACD Line and 🟠 Signal Line show crossover momentum
🟩/🟥 Histogram shows distance from the signal line
🟪 Adjusted Donchian Midline dynamically adapts to range-bound vs trending environments
Background Color provides real-time trend state:
✅ Green = Bullish Trend
❌ Red = Bearish Trend
No color = Neutral / Choppy
MACD Boundaries (user-defined):
Overbought: +1.0
Oversold: -1.0
🔀 3. Divergence Detection
Spot hidden power shifts before price reacts:
🔼 Positive Divergence – Price makes lower lows, but MACD histogram rises
🔽 Negative Divergence – Price makes higher highs, but MACD histogram weakens
These are visually marked with:
Green “+Div” label (bullish reversal cue)
Red “–Div” label (bearish exhaustion signal)
🎯 How to Use It
For Trend Traders:
Stay in sync with macro trend using MACD histogram + background
Use ATPC crossovers for precision entries
Avoid signals during neutral background (chop filter)
For Reversal Traders:
Look for bullish +Div with ATPC buy signal in oversold zone
Look for bearish –Div with ATPC sell signal in overbought zone
Mid-Donchian line can act as confluence or breakout trigger
For Scalpers & Intraday Traders:
Combine with VWAP, liquidity zones, or order flow levels
ATPC crossovers + MACD histogram zero-line flip = potential scalp entry
Use histogram slope and divergence to avoid false momentum traps
🧩 Customizable Inputs
🎛️ ATPC: Channel & Smoothing lengths, overbought/oversold thresholds
🎛️ MACD: Fast/slow EMAs, signal smoothing, Donchian period, bounds
🎨 Fully theme-compatible with adjustable colors and line styles
🔔 Alerts (Add Your Own)
While this version doesn’t contain built-in alerts, you can easily add alerts based on:
buySignal or sellSignal from ATPC logic
Histogram cross zero or trend flip
MACD Divergence event
📜 “This indicator doesn't just show signals—it tells a story about who’s in control of the market, and when that control might be slipping.”
🔍 Overview:
This powerful dual-system indicator merges two proven analytical engines:
✅ The Algorganic Typical Price Channel (ATPC) — a custom trend oscillator that highlights mean-reversion and directional bias.
✅ A refined MACD system with divergence detection, enhanced with an adjusted Donchian midline for real-time trend strength filtering.
Together, they provide a high-confidence, multi-signal system ideal for swing trading, scalping, or confirming reversals with context.
⚙️ Core Components & Logic
🧠 1. ATPC Engine (Trend Commodity Index)
A momentum and volatility-normalized oscillator based on the typical price (H+L+C)/3:
TrendCI Line (Blue) – Main trend signal based on smoothed CCI logic.
TrendLine2 (Orange) – A slower smoothing of TrendCI for crossovers.
Key Zones (customizable):
🔴 Ultra Overbought: +73
🟣 Overbought: +58
🟣 Oversold: -58
🔴 Ultra Oversold: -73
Trade Logic:
✅ Buy Signal: TrendCI crosses above TrendLine2 while in oversold zone
❌ Sell Signal: TrendCI crosses below TrendLine2 while in overbought zone
Additional visual feedback:
Histogram Bars show strength and direction of momentum shift
Green/Red Circles highlight potential long/short setups
📉 2. MACD System + Divergence Finder
Classic MACD enhanced with a Donchian Midline overlay to filter trend bias.
🔷 MACD Line and 🟠 Signal Line show crossover momentum
🟩/🟥 Histogram shows distance from the signal line
🟪 Adjusted Donchian Midline dynamically adapts to range-bound vs trending environments
Background Color provides real-time trend state:
✅ Green = Bullish Trend
❌ Red = Bearish Trend
No color = Neutral / Choppy
MACD Boundaries (user-defined):
Overbought: +1.0
Oversold: -1.0
🔀 3. Divergence Detection
Spot hidden power shifts before price reacts:
🔼 Positive Divergence – Price makes lower lows, but MACD histogram rises
🔽 Negative Divergence – Price makes higher highs, but MACD histogram weakens
These are visually marked with:
Green “+Div” label (bullish reversal cue)
Red “–Div” label (bearish exhaustion signal)
🎯 How to Use It
For Trend Traders:
Stay in sync with macro trend using MACD histogram + background
Use ATPC crossovers for precision entries
Avoid signals during neutral background (chop filter)
For Reversal Traders:
Look for bullish +Div with ATPC buy signal in oversold zone
Look for bearish –Div with ATPC sell signal in overbought zone
Mid-Donchian line can act as confluence or breakout trigger
For Scalpers & Intraday Traders:
Combine with VWAP, liquidity zones, or order flow levels
ATPC crossovers + MACD histogram zero-line flip = potential scalp entry
Use histogram slope and divergence to avoid false momentum traps
🧩 Customizable Inputs
🎛️ ATPC: Channel & Smoothing lengths, overbought/oversold thresholds
🎛️ MACD: Fast/slow EMAs, signal smoothing, Donchian period, bounds
🎨 Fully theme-compatible with adjustable colors and line styles
🔔 Alerts (Add Your Own)
While this version doesn’t contain built-in alerts, you can easily add alerts based on:
buySignal or sellSignal from ATPC logic
Histogram cross zero or trend flip
MACD Divergence event
📜 “This indicator doesn't just show signals—it tells a story about who’s in control of the market, and when that control might be slipping.”
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。