Skip to content
All library documents

Drawing Transparent Indicator Channels with MQL5 Canvas

Article MQL5 articles

Summary

The article shows how to use MQL5’s CCanvas class to draw custom indicator graphics, focusing on transparent fills between two lines. It motivates canvas drawing as an alternative to the built-in fill plot, which does not support transparency and can blend awkwardly with candles, chart objects, and other indicators. The implementation obtains chart dimensions, visible-bar information, scale, and price bounds, then converts between chart values or bar indices and pixel coordinates.

The tutorial builds a canvas lifecycle for creating and destroying a bitmap label, erasing and redrawing its contents, and updating it when chart properties change. It then applies the coordinate methods to a filled indicator channel and extends the approach to subwindows. The evidence is a worked indicator implementation and its displayed result, rather than a trading-performance evaluation. The method concerns visualization and chart rendering; correct behavior depends on keeping the canvas dimensions and coordinate mapping synchronized with chart changes.

Key ideas

  • CCanvas enables custom indicator graphics with transparency that the built-in fill plot does not provide.
  • Chart dimensions, visible bars, scale, and price bounds support conversion between chart coordinates and pixels.
  • A canvas drawing cycle creates the bitmap resource, clears and redraws it, updates it, and destroys it during cleanup.
  • Chart-change events can trigger resizing and redrawing as the user changes the view.
  • The channel-fill technique can be adapted from the main chart to indicator subwindows.

Tags

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