Skip to content
All library documents

Building Mouse-Responsive Chart Overlays with the iCanvas Library

Article MQL5 code base

Summary

This example explains how a MetaTrader indicator can use an iCanvas library to draw an interactive overlay on a price chart. A timer checks whether the mouse has moved; when it has, the indicator redraws a soft spot, a price information panel, crosshairs, and labels for the cursor’s price and time. The accompanying library description outlines a full-window canvas that resizes with the chart, a window structure with chart and mouse coordinates, and helper methods for converting between screen positions and bars, times, and price data.

The example is a graphics and interface technique rather than a trading signal or tested strategy. It notes that an OnChartEvent handler is optional and that automatic window updates do not apply to scripts. The document does not discuss performance costs, error handling, or testing across chart configurations, so users adapting the approach would need to account for those implementation details themselves.

Key ideas

  • The iCanvas instance can cover the chart window and resize automatically for indicators.
  • Mouse coordinates and chart data can be used to draw price, time, and bar information near the cursor.
  • A timer can update the overlay only after the mouse position changes.
  • The example demonstrates chart interface code, not a trading method or evidence of strategy performance.

Tags

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