Skip to content
All library documents

Pearson Correlation of Moving Averages Across Two Instruments

Article MQL5 code base

Summary

This indicator calculates the Pearson product-moment correlation between moving-average values for two selected financial instruments. Its reading ranges from negative one to positive one: positive values indicate that the two series move together linearly, negative values indicate an inverse linear relationship, and a value near zero indicates little linear association. The user can select the moving-average period, both instrument symbols, and the applied price for each instrument.

The post notes practical data and update requirements. Invalid symbol names cause an error and unload the indicator. Required price history must be available, and if the first selected instrument differs from the chart instrument, updates wait for a new tick on the chart instrument. This is a descriptive measure of historical co-movement, not evidence of causation or a trading strategy; the description gives no performance tests or guidance on selecting instruments or periods.

Key ideas

  • The indicator measures linear correlation between moving-average values for two instruments.
  • Its scale runs from negative one through zero to positive one, indicating inverse, weak, or positive association.
  • The moving-average period, symbols, and applied prices are configurable.
  • Missing history or invalid symbols affect whether the indicator can display values.
  • When the selected instrument differs from the chart instrument, updates depend on ticks arriving for the chart instrument.

Tags

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