Skip to content
All library documents

Using Object-Oriented Design to Build a Price Action Expert Advisor

Article MQL5 articles

Summary

This article explains object-oriented programming (OOP) through an MQL5 price action Expert Advisor, with the main goal of illustrating code organization rather than teaching a trading strategy. It introduces classes as blueprints for objects, attributes as stored properties, and methods as the functions objects can perform. A phone analogy helps distinguish a class from individual objects created from it.

The discussion then moves to class structure, access modifiers, constructors, and destructors, before applying OOP concepts to refactor a procedural Expert Advisor that uses an exponential moving average and candlestick data. Code examples illustrate class declarations and initialization. The article’s strategy example is deliberately simple and serves as a programming demonstration; it does not present evidence that the trading rules are profitable. The supplied text is incomplete in places, so it does not support a detailed assessment of the full implementation or any trading performance.

Key ideas

  • A class groups data attributes and methods into a reusable blueprint.
  • An object is an instance of a class with its own state and behavior.
  • Constructors initialize an object when it is created, while destructors handle cleanup when it is removed.
  • The article uses a simple EMA and candlestick Expert Advisor to demonstrate a procedural-to-OOP refactor.
  • The programming example is educational and does not establish the quality or profitability of its trading logic.

Tags

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