Skip to content
All library documents

Connecting an MQL5 Expert Advisor to a Position Display Indicator

Article MQL5 articles

Summary

This installment in a market replay and simulation series explains how to separate position visualization from an Expert Advisor while maintaining communication between them. The EA provides the link to the trading server, while an indicator displays open positions on the chart. The article argues that this separation can make features easier to reuse across multiple EAs, and begins developing message exchange between the EA and position indicator.

It also handles stale chart objects after a crash: on initialization, the EA checks open positions against the current symbol and removes mismatched position indicators before attaching indicators for matching positions. The examples show chart events and custom messages as the basis for interaction. This is an educational implementation discussion, not a trading method or performance study. The author cautions that the message-based design is deliberately simple and may reduce responsiveness, and advises testing and understanding the code before using it in a real account.

Key ideas

  • An Expert Advisor can manage server interaction while a separate indicator renders open positions.
  • Separating chart display from EA logic can simplify reuse across multiple Expert Advisors.
  • On startup, the EA can remove stale indicators that do not match current open positions.
  • Chart events and custom messages provide a communication path between the EA and indicator.
  • The implementation is educational and should be understood and tested before live use.

Tags

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