Confirmed MACD Divergence with Netting
- エキスパート
- バージョン: 1.2
- アップデート済み: 27 8月 2026
- アクティベーション: 5
MACD Divergence Expert Advisor
MACD Divergence Expert Advisor is a MetaTrader 4 trading robot that identifies divergence between price swing trends and MACD swing trends. It supports regular and hidden bullish and bearish divergence, optional signal confirmation filters, configurable risk management, trade netting, exposure controls, and configurable trading and wind-down modes.
The EA searches for significant price and MACD peaks and troughs, builds two-point trends from matching swing markers, and compares the direction of those trends. A trade signal is considered only when the configured swing separation, time overlap, and price/MACD alignment requirements are satisfied.
Divergence Types
- Regular bullish: price makes a lower trough while MACD makes a higher trough.
- Regular bearish: price makes a higher peak while MACD makes a lower peak.
- Hidden bullish: price makes a higher trough while MACD makes a lower trough.
- Hidden bearish: price makes a lower peak while MACD makes a higher peak.
Signal Process
The EA operates on new bars. It detects price and MACD swing points, builds corresponding trends, checks the divergence structure, and then runs any enabled confirmation filters.
If the signal is accepted, optional stop-loss and take-profit levels are calculated before the trade is passed to the TradeNet booking, netting, exposure-management, and trade-mode system.
Trend Identification
Detection can be adjusted using SearchBars, separate minimum prominence settings for price and MACD, minimum and maximum swing separation, maximum price/MACD swing alignment, and minimum trend overlap.
The MACD calculation can be configured using:
- MACDFast
- MACDSlow
- MACDSignal
- MACDPrice
Optional Trade Confirmation
All confirmation filters are optional. When several confirmers are enabled, all enabled confirmers must approve the signal.
- Price Bar Confirmer: checks whether the previous completed candle agrees with the trade direction.
- MACD Momentum Confirmer: checks whether the MACD main line is moving in the trade direction.
- Price Change Confirmer: requires a minimum preceding price move over a configurable lookback.
- MACD Divergence Quality Confirmer: scores divergence structure using price swing size, MACD swing size, alignment, and swing separation.
- MACD Signal Confirmer: can confirm either MACD main/signal direction or a recent crossover.
- MACD Swing Signal Line Interaction Confirmer: checks whether the MACD main and signal lines crossed, or came sufficiently close, between the two MACD swing points.
- High Volume Regime Confirmer: compares recent average tick volume with an earlier non-overlapping baseline.
Risk Management
An optional stop loss can be placed relative to the price trend high or low with a configurable point buffer.
An optional take profit can then be calculated from the stop-loss distance using a configurable risk/reward ratio.
Trade Netting and Exposure
The EA includes TradeNet logic for trade booking, position netting, exposure control, and controlled position wind-down.
Netting can be:
- Disabled
- Limited to positions opened by this EA
- Applied to all market positions for the symbol
Exposure can likewise be calculated from this EA's positions or all market positions for the symbol.
MaxExposure sets the maximum permitted absolute net exposure. Set MaxExposure = -1 to disable the exposure limit.
Exposure control is direction-aware. Opposite-direction trades may first reduce existing exposure before any remaining trade amount is considered for a new position.
Trade Modes and Wind-Down
The EA provides configurable TradeMode options to control whether new positions may be opened and whether existing opposing positions may be reduced.
Available modes include:
- Standard: normal trading. Eligible opposing positions may be reduced through netting and remaining trade size may be opened subject to exposure, margin, broker, and execution checks.
- None: disables trading activity without treating the lack of a trade as an execution error.
- Wind-down: existing opposing positions may be reduced by qualifying signals, but no new remaining exposure is opened.
- Market-close wind-down: trades normally outside the configured wind-down period, then switches to reduction-only behaviour before the end of the current broker trading session.
WindDownHours controls how many hours before the end of the current active broker-defined trading session the market-close wind-down period begins.
This allows strategies to limit or reduce exposure near market close without requiring all positions to be closed automatically at a fixed time.
Trade Execution
Trade execution settings include:
- LotSize
- TradeMode
- WindDownHours
- SlippagePoints
- MagicNumber
- CooldownBars
The cooldown is measured in bars after a successful position change, including either a newly opened trade or a reduction of existing exposure.
Trade size and prices are checked against applicable broker constraints before execution, including minimum and maximum lot size, lot step, available margin, price precision, and valid stop-loss/take-profit distances where applicable.
Default Profile
- MACD: 12 / 26 / 9
- SearchBars: 5
- Swing separation: 5 to 50 bars
- Maximum swing alignment: 5 bars
- Minimum trend overlap ratio: 0.75
- All optional confirmers: Disabled
- Stop loss: Disabled
- Take profit: Disabled
- Maximum exposure: 10
- Trade mode: Standard
- Cooldown: 5 bars
Chart Setup
The EA can operate without the MACD indicator being manually added to the chart.
For visual alignment of the MACD trend drawings, add the standard MACD indicator and set its fast, slow, and signal periods to match the EA's MACDFast, MACDSlow, and MACDSignal inputs.
Testing and Use
Parameters ending in Points use the broker's point size and do not necessarily represent pips.
Broker spread, lot limits, lot step, margin requirements, trading sessions, and price precision affect execution.
The market-close wind-down feature uses the trading-session information provided by the broker for the selected symbol. It applies to the current active trading session and does not provide a separate market-holiday calendar.
Before live use, test the EA in the MetaTrader 4 Strategy Tester using realistic spread and execution assumptions. Review the Experts and Journal logs and forward-test the selected settings on a demo account.
Important
Divergence signals do not guarantee a reversal or profitable trade. The default settings are a starting point for testing and are not guaranteed to be suitable for every symbol, timeframe, broker, or market condition.
