Skip to content
All library documents

MACD Zero-Cross Signals with a Minimum Distance Filter

Article MQL5 code base

Summary

This document describes an expert advisor that checks for MACD entry signals when a new bar appears, while managing trailing stops on every tick. A buy setup requires the MACD main line to be below zero, cross above its signal line, and exceed a configurable minimum distance from zero. The sell setup mirrors those conditions above zero. The distance threshold is converted from points using the instrument’s point size.

When a new signal appears, the advisor closes positions in the opposite direction. The document provides the entry conditions and identifies EURUSD and USDJPY on a 15-minute chart, but supplies no performance statistics, risk controls, or detailed trailing-stop rules. It therefore explains signal logic rather than demonstrating profitability; the parameters and behavior would need independent evaluation across instruments and market conditions.

Key ideas

  • The advisor evaluates entry signals only when a new bar forms and updates trailing stops on every tick.
  • A buy signal requires the MACD main line to cross above the signal line while remaining below zero.
  • A sell signal requires the inverse crossover while the main line remains above zero.
  • Both signals must exceed a configurable distance from zero measured in instrument points.
  • A new signal closes open positions in the opposite direction.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.