MetaTrader 5 MT5 Libraries IncOBVOnArray – library MetaTrader 5

IncOBVOnArray – library MetaTrader 5

The COBVOnArray class is intended for calculation of OBV (On Balance Volume) on indicator buffers.

Usage:

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

  • int aPeriod is indicator period. If the value is set to 0 (default), the indicator will work like the one included in the client terminal – it will be calculated for all bars of the chart. Any other positive value sets the number bars of used for calculation of value for each bar (moving average principle).

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

  • const int aRatesTotal is the rates_total variable from the OnCalculate() function parameters;
  • const int aPrevCalc is the prev_calculated variable from the OnCalculate() function parameters;
  • double aDataClose[] is the buffer with the Close data for the indicator calculation;
  • double aDataVolume[] is the buffer with the Volume data for the indicator calculation;
  • double & aOBV[] is the buffer with calculated value.

Additional methods:

  • int BarsRequired() returns the minimum number of bars required for the indicator calculation;
  • string Name() returns a string with the indicator name.
Alternative:   Exp_AFIRMA - EA MetaTrader 5

The Test_OBVOnArray.mq5 file is an indicator demonstrating how to use the COBVOnArray class. The IncOBVOnArray file must be located in the MQL5\Include\IncOnArray directory of the terminal data folder (the IncOnArray folder must be created).

On Balance Volume Technical Indicator (OBV) is a momentum technical indicator that relates volume to price change. The indicator, which Joseph Granville came up with, is pretty simple. If the close price of the current bar is higher than that of the previous bar, the volume of the current bar is added to the previous OBV. If the current bar close price is lower than of the previous one, the current volume is subtracted from the previous OBV.

An example of using the CObvOnArray class


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