Skip to content
All library documents

Restructuring an MQL5 Expert Advisor for Templates and Floating Windows

Article MQL5 articles

Summary

This installment explains a substantial refactor of an MQL5 Expert Advisor to support user-selected chart templates, subwindows, and floating windows while retaining existing trading functionality. It describes tracking template changes during initialization so timeframe changes do not unnecessarily reset floating windows, and using a support indicator alias to locate or create a chart subwindow when needed.

The article also outlines a more standardized way to parse user requests for chart templates and indicators, and moves event handling into object classes to keep the EA event function simpler. Floating windows retain separate positions and dimensions when minimized or maximized, allowing users to place each state independently. The material is primarily software architecture and interface implementation rather than a trading strategy; it gives code examples and design rationale but no strategy performance evidence or testing results. Its practical value is for developers extending chart-based tools in MetaTrader 5.

Key ideas

  • The EA refactor separates chart, wallpaper, volume-at-price, and subwindow responsibilities into classes.
  • A remembered template setting helps avoid rebuilding floating windows after timeframe changes.
  • A support indicator alias lets the EA find or create its chart subwindow on demand.
  • Event dispatch within object classes can reduce complexity in the main EA event handler.
  • Minimized and maximized floating windows can keep independent positions and dimensions.

Tags

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