Skip to content
All library documents

MQL5 Basics and a Daily-Range Breakout Expert Advisor

Article MQL5 articles

Summary

This introductory article explains MQL5 program types, event-driven functions, data types, compilation, and debugging through examples of an expert advisor and a custom indicator. Its trading example places buy-stop and sell-stop orders just outside the day’s range at a specified morning time, accounting for spread on the buy side. Stops begin on the opposite side of the range and later trail using a moving average. A daily ATR sets a volatility-dependent profit target, and pending orders are removed in the evening.

The article is mainly a programming tutorial, not a validated strategy study. It explains how the example can be represented in MQL5 and displayed with an indicator, but supplies no performance evidence establishing profitability. Its assumptions about intraday EURUSD trends and the chosen times and indicator settings are illustrative and may not generalize across instruments, brokers, or market conditions. The distinction among orders, deals, and positions is also introduced as a platform concept.

Key ideas

  • MQL5 programs respond to platform events such as initialization, new ticks, timer triggers, and chart actions.
  • The example breakout system places stop orders beyond the current day’s range at a scheduled time.
  • A moving average trails stops, while daily ATR determines volatility-adjusted profit targets.
  • The article demonstrates indicator and expert advisor construction but does not validate the strategy’s profitability.
  • Order, deal, and position represent distinct stages or states in MetaTrader’s trading model.

Tags

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