Passing Parameters from an MQL5 Expert Advisor to a Chart Indicator
Summary
This article demonstrates the first stage of communication between an MQL5 Expert Advisor and a custom indicator: passing an input value when creating the indicator. The EA first searches the chart for an existing instance and reuses its handle; if none is found, it loads the custom indicator with iCustom and attaches it to the chart. The indicator prints the received value, providing a simple way to verify that the parameter transfer worked.
The explanation covers matching parameter order and types, choosing the symbol and timeframe, and specifying the indicator’s location for loading. It also stresses attaching an indicator to the chart and cleaning up its chart instance and handle when the EA stops. This is a setup and integration example, not a trading strategy or performance study. Communication is only shown from the EA to the indicator; transferring information back to the EA remains unresolved, and the article presents terminal global variables as a possible fallback if this approach proves unsuitable.
Key ideas
- The EA can retrieve an existing chart indicator handle or load the indicator with iCustom if none is present.
- Custom indicator inputs are supplied after the symbol, timeframe, and indicator name, in matching order and type.
- Attaching the indicator to the chart is part of the illustrated setup, and the EA deletes the chart instance and releases the handle on shutdown.
- The example demonstrates one-way parameter transfer from the EA to the indicator, not a complete two-way communication system.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.