Skip to content
All library documents

Connecting a Position Indicator to an Expert Advisor in MetaTrader 5

Article MQL5 articles

Summary

This installment explains how a MetaTrader 5 position-view indicator can work with an Expert Advisor, Chart Trade, and a mouse interaction indicator. The EA manages when the position indicator is added or removed, while the indicator remains a separate component that can be reused and updated without rebuilding each EA that uses it.

The article describes the system’s event-driven approach: applications communicate through chart messages, and the EA announces contract settings to other components. It outlines changes to the indicator and EA needed to associate an indicator instance with a particular open position. The evidence is an implementation walkthrough and code excerpts from the existing EA and revised indicator; the article does not report trading tests or performance results. It is an incremental programming tutorial, and the excerpt omits much of the revised indicator code. It also postpones pending-order handling and the indicator’s coordination with price-line controls to later work.

Key ideas

  • The Expert Advisor, Chart Trade, mouse indicator, and position indicator form a cooperating chart-based system.
  • The EA adds and removes a position indicator automatically when a relevant position exists.
  • Keeping the indicator separate allows shared fixes and improvements to reach multiple Expert Advisors.
  • The applications coordinate through event messages rather than direct user commands.
  • Pending orders and price-line interaction are left for later installments.

Tags

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