OPEN-SOURCE SCRIPT

Combined ATPC & MACD Divergence

163
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.”

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.