OPEN-SOURCE SCRIPT
Обновлено

MACD & DMI/ADX Context (MTF)

928
MACD & DMI/ADX Context (MTF)

MACD & DMI/ADX Context (MTF) is a compact market-context indicator that combines MACD momentum structure with DMI/ADX trend strength in one workflow. The script includes a controlled Execution Mode (confirmed vs realtime behavior), a unified background engine for cleaner charts, an event-based alert system, and an optional divergence module.

The focus is on regime context, pullback awareness, and confirmationnot on ready-made signals.
Concept
Many traders use MACD to read momentum shifts and pullback phases, while DMI/ADX is used to separate trending from ranging conditions and to judge directional dominance and strength.

This script is designed to keep those reads consistent and visually accessible while reducing noise. Instead of stacking multiple indicators with overlapping signals, it provides a single context layer where momentum, direction, and strength can be monitored together.

Two analysis approaches are available:
  • MACD Mode -> momentum structure (MACD line, signal line, histogram) + optional context backgrounds and alerts
  • DMI/ADX Mode -> directional dominance (+DI/-DI) + trend strength (ADX) + optional context backgrounds and alerts

This helps keep a clean chart without losing important momentum/strength context.

Core Features

1) Two-Mode Workflow (MACD / DMI-ADX)

A practical split between momentum reading and trend-strength reading.
  • MACD Mode: MACD line, signal line, histogram, optional histogram pattern markers
  • DMI/ADX Mode: +DI / -DI / ADX, optional ADX plotting and threshold context
  • Unified workflow so you can switch perspective without changing scripts

2) Execution Mode (Confirmed vs Realtime)

A transparent control over repaint sensitivity and live responsiveness.
  • Confirmed Only (Non-Repaint) -> visuals and alerts update only on bar close
  • Realtime Visuals + Confirmed Alerts -> intrabar visuals, close-confirmed alerts
  • Realtime Visuals + Realtime Alerts (May Repaint) -> intrabar visuals and alerts (explicitly may repaint)

This allows clean backtest/automation-friendly behavior, or faster live reading—depending on your preference.

3) Unified Background Engine (Clean Context Layer)

Instead of multiple overlapping background calls, the script uses a single priority-based background engine.
  • MACD context backgrounds (CTF / optional HTF, slope, zero-line regimes)
  • DMI/ADX context backgrounds (DI dominance, ADX slope/range context, optional HTF)
  • Reduced visual clutter while keeping bias readable at a glance

4) Multi-Timeframe Context (MTF)

Optional next-higher-timeframe context is available for both MACD and DMI.
  • Displays the next higher supported timeframe bias when enabled
  • Helps align lower timeframe decisions with higher timeframe direction/strength
  • Includes optional compact MTF ADX histogram snapshots (4H / D / W / M)

5) Event-Based Alerts (No Spam)

Alerts are implemented as events (cross/flip/start/end), not continuous states.

MACD Lines Alerts
  • MACD↔Signal cross (up/down)
  • Bull/Bear regime start/end (MACD above/below signal)
  • MACD zero-line cross and Signal zero-line cross
  • Optional “cross near zero” filtering
  • MACD slope flips and Signal slope flips
  • Proximity enter alert when |MACD−Signal| enters a threshold

MACD Histogram Alert Package
  • Histogram zero cross and slope flip
  • Grow/Fall regime flips above/below zero
  • Confirmed pivot peaks/troughs
  • Compression → expansion (“Ignition”)

DMI/ADX Alerts
  • +DI↔-DI cross and DI dominance regime start/end
  • ADX threshold cross and ADX slope flip
  • ADX strong+rising state start/end
  • Optional Long_2 / Short_2 state start/end (DI direction + ADX threshold participation state)

6) Divergence Module (Pivot-Based, Compact Markers)

A single divergence selector keeps the UI simple.
  • Off
  • Histogram Divergence -> price pivots vs MACD histogram
  • MACD Line Divergence -> price pivots vs MACD line

Divergences are pivot-confirmed and plotted as compact dot markers positioned close to the oscillator, with an optional vertical offset for readability.

Applications (Ambitious Beginners)

A) Clean Regime Filter Before You Decide
  • Use the background as a bias filter (trend vs range / bullish vs bearish context)
  • Then apply price action and risk management on top

B) Pullback vs Continuation Awareness
  • In trends, ADX and DI dominance help judge whether MACD shifts are likely continuation or deeper pullback
  • In ranges, histogram compression/ignition and divergence can highlight transition phases

C) Learn With Less Noise
  • Use Confirmed Only mode for clean learning and replay
  • Enable only one alert group at a time (MACD lines, histogram, or DMI/ADX)
  • Build structure first, then add confirmation layers

Applications (Advanced Traders)

1) Confluence Mapping (Momentum + Strength)
  • MACD regime + histogram behavior (momentum)
  • DI dominance + ADX strength/slope (trend quality)
  • Optional next-higher-timeframe bias alignment

Goal: build confluence-based decisions, not isolated signals.

2) Regime / Context Shift Observation
  • Monitor transitions: ignition + ADX strength changes + regime flips
  • Separate “momentum impulse” from “trend acceptance”
  • Use events and state transitions for structured decision timing

3) Alert Workflow for Discretionary Traders
  • Event-based alerts act as “attention triggers”
  • You decide execution using structure, levels, and risk rules
  • Execution Mode lets you choose strict confirmation or faster intrabar visuals

Notes
  • This script is a context and analysis tool, not an automated trading system.
  • MACD/DMI/ADX are derived measures and can lag; interpret them with price structure, volatility, and risk management.
  • Execution Mode exists to make repaint/confirmation behavior explicit and user-controlled.

Best Suited For
  • Ambitious beginners learning structured chart reading
  • Discretionary intraday and swing traders
  • Traders who want a clean context layer instead of signal spam
  • Users who combine momentum shifts with trend strength confirmation

Versioning / Legacy Notice

This publication is a major successor to my earlier script “MACD/DMI ADX”, which remains available as a legacy version for users who rely on its previous workflow and behavior.

What’s new in this release:
  • Pine Script v5 → v6 migration
  • Mode-based workflow (MACD vs DMI/ADX)
  • Execution Mode (confirmed vs realtime control)
  • Unified background engine (cleaner, consistent context)
  • Event-based alert architecture + expanded histogram alert package
  • Refined divergence module with compact markers
  • Usability and performance improvements
Информация о релизе
MACD Divergence revised.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.