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

2012.01.11 13:47

IncADOnArray - library for MetaTrader 5

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

votes: 12


CADOnArray class is designed for calculation of AD (Accumulation Distribution, A/D) values on indicator buffers.


Init() method with the optional parameter is called in the OnInit() function:

  • int aPeriod - indicator period. In case the value is equal to 0 (by default), the indicator works the same way (is calculated by all chart bars) as the one built in the terminal. In case of any other positive value specified number of bars is used (Moving Average principle) for value calculation at each chart bar.

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 aDataHigh[] - the buffer with the High data for the indicator calculation;
  • double aDataLow[] - the buffer with the Low data for the indicator calculation;
  • double aDataClose[] - the buffer with the Close data for the indicator calculation;
  • double aDataVolume[] - the buffer with the Volume data for the indicator calculation;
  • double aAD[] - the buffer with the calculated value.

Additional methods:

  • int BarsRequired() - returns the minimum number of bars for the indicator calculation;
  • string Name() - returns the line with the indicator name.

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

Accumulation/Distribution (A/D) Technical Indicator is determined by the changes in price and volume. The volume acts as a weighting coefficient at the change of price - the higher the coefficient (the volume) is, the greater the contribution of the price change (for this period of time) will be in the value of the indicator.


Example of use of CADOnArray 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.

TypeToBytes TypeToBytes

Byte-wise operation with structures and standard data types.

PriceLines PriceLines

Script for drawing a price markup.