Skip to content
All library documents

Calculating Momentum with a Ring Buffer

Article MQL5 code base

Summary

This document describes a software class for calculating the Momentum indicator with a ring buffer. It provides methods to initialize the indicator, process a full input array, or update the calculation from individual values. The class also exposes the required bar count, indicator name, period, and buffer size.

The examples show how to calculate Momentum from a price series and read values from the buffer using time-series indexing. A second example applies Momentum to data from an existing Momentum buffer, illustrating how the value-based method can support chained indicator calculations. The document focuses on implementation and data access rather than defining a trading rule. It gives no evidence that Momentum signals are profitable, and users must handle period selection and interpretation separately.

Key ideas

  • A ring buffer can store Momentum calculations while limiting the retained data window.
  • The class supports calculation over an array or incremental calculation from individual values.
  • Its accessors report the period, buffer size, indicator name, and required bars.
  • Examples demonstrate reading results and using one Momentum series as input to another.

Tags

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