Skip to content
All library documents

Creating MQL5 Moving Averages as Line and Candle Indicators

Article MQL5 articles

Summary

This beginner tutorial shows how to build custom indicators in MQL5 without relying on built-in moving-average routines. Its first example calculates three moving averages from different price inputs and displays them as lines. The tutorial introduces indicator buffers and plots, input periods, initialization, and the OnCalculate process for working through bar data.

A second example represents a short-period moving average in candle form, using buffers for candle prices and a color buffer to distinguish rising from falling values. The article explains that indicators analyze and display data, whereas Expert Advisors can also execute trades. It gives implementation guidance and conceptual examples, but no backtest, signal evaluation, or evidence that these moving averages improve trading decisions. Results depend on the chosen periods and display design, which are presented as educational examples rather than validated strategies.

Key ideas

  • Custom indicators let developers define their own calculations and chart presentation.
  • Indicator buffers store calculated values that plots use to draw lines or candles.
  • The line example calculates averages from high, close, and open prices using separate periods.
  • The candle example averages price fields and assigns colors according to the resulting direction.
  • Indicators display analysis but do not place trades, and the examples are not performance-tested strategies.

Tags

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