MQL5 Chart Objects, Keyboard Events, and Indicator Updates
Summary
This programming tutorial explains how MQL5 indicators can create and move chart objects, respond to keyboard input, and coordinate with other applications on a chart. Its examples include a horizontal line that displays the prior quote’s price, a keyboard event handler that prints key codes, and keyboard controls for moving an object. The discussion emphasizes that an indicator calculation event does not necessarily mean the price changed: repeated calculations at the same price can make the displayed line coincide with the current price.
The article also introduces chart events as a way to capture user interaction and use key presses to control graphical objects. Later material discusses indicator naming and short names as practical conventions. These examples teach platform behavior and basic event-driven programming rather than a trading signal or strategy. The article is introductory, uses simplified examples, and does not present performance tests or evidence that the techniques improve trading results.
Key ideas
- MQL5 indicators can create chart objects during initialization and update their positions as calculations run.
- A calculation event may occur without a price change, so object movement should not assume that each event represents a new quote.
- An OnChartEvent handler can capture keyboard events and expose key codes for application controls.
- Indicator short names help identify indicators in the platform and should describe their purpose.
- The examples demonstrate interface programming and platform behavior, not a tested trading method.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.