Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2011.12.14 12:30

IncMAOnArray - library for MetaTrader 5

| English Русский 中文 Español Deutsch 日本語 Português

votes: 18


CMAOnArray class is designed for Moving Average calculation on indicator buffer's data.


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

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

  • const int aRatesTotal - rates_total variable from the OnCalculate() function parameters;
  • const int aPrevCalc - prev_calculated variable from the OnCalculate() function parameters;
  • double aData[] - buffer with the data, according to which MA is calculated;
  • double aMA[]  - the buffer with calculated МА.
Additional methods:
  • int BarsRequired() - returns the minimal number of bars necessary for calculation;
  • string Name() - returns the line with the indicator name;
  • string NameMethod() - returns the line with the name of the used smoothing method.

Test_MAOnArray.mq5 is a sample indicator showing CMAOnArray class application. IncMAOnArray file must be located in MQL5\Include\IncOnArray of the terminal data folder (IncOnArray folder must be created).

The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average, one averages out the instrument price for this time period. As the price changes, its moving average either increases, or decreases.

Example of use of CMAOnArray class

Translated from Russian by MetaQuotes Software Corp.
Original code:

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

Average Directional Movement Index (ADX) Average Directional Movement Index (ADX)

The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.

TP-SL_Removing TP-SL_Removing

Immediately deletes the SL/TP of all positions.

Closed_TOTAL Closed_TOTAL

Total closure of all positions (winners/losers). You can also select which are of a single instrument.