Skip to content
All library documents

Color-Coding Moving Averages in the Strategy Tester

Article MQL5 code base

Summary

The document describes a custom moving average indicator that accepts a line color parameter, helping traders distinguish multiple moving averages in the MetaTrader visual strategy tester. It says that moving averages accessed through the standard iMA function all appear red in that display, making it difficult to tell them apart when an expert advisor uses several averages.

The proposed workaround is to create the indicator through iCustom and pass the desired color as an input. The document illustrates this change using an expert advisor that compares two moving averages, including a check for an invalid indicator handle. Its evidence is a stated visual result in the tester; it does not provide performance measurements or claim to alter indicator calculations. The guidance is specific to the described MetaTrader setup and addresses display clarity during testing, rather than strategy design or trading outcomes.

Key ideas

  • The standard moving average display can render multiple averages in the same color in visual testing.
  • A custom indicator adds a configurable line color for clearer chart inspection.
  • An expert advisor can access the colored indicator through iCustom.
  • The example checks whether the indicator handle was created successfully.

Tags

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