IncMomentumOnArray – library MetaTrader 5

CMomentumOnArray class is designed for calculation of Momentum values on indicator buffers.

Usage:

Init() method with the following parameters is called in the OnInit() function:

  • int aPeriod – indicator period.

Solve() method with the following parameters is called in the OnCalculate() function:

  • const int aRatesTotal is a rates_total variable from the OnCalculate() function parameters;
  • const int aPrevCalc – prev_calculated variable from the OnCalculate() function;
  • double aData[] – data buffer for the indicator calculation;
  • double aMomentum[] – the buffer with the indicator calculated value.

Additional methods:

  • int BarsRequired() – returns the minimum number of bars for the indicator calculation;
  • int BarsRequiredPDIMDI() – returns the minimum number of bars for PDI and MDI calculation;
  • string Name() – returns the line with the indicator name.

Test_MomentumOnArray.mq5 is a sample indicator showing CMomentumOnArray class application. IncMomentumOnArray file must be placed to MQL5\Include\IncOnArray of the terminal data folder (IncOnArray folder must be created).

Alternative:  FX5_SelfAdjustingMFI - indicator MetaTrader 5

The Momentum Technical Indicator measures the amount that a security’s price has changed over a given time span. It can be used both as a trend-following and a leading indicator.

Example of use of the CMomentumOnArray class


📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks