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.17 11:40

IncBandsOnArray - library for MetaTrader 5

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

votes: 23

The CBandsOnArray is intended for calculation of Bollinger Bands ® (BB) on an indicator buffer.


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

  • int aPeriod is indicator period;
  • ENUM_MA_METHOD aMethod is a method of averaging for calculation of the standard deviation;
  • double aDeviation is a width of bands (the number of standard deviations).

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 aData[] is a buffer with data for the indicator calculation;
  • double & aMA[] is a buffer with calculated values of the central line;
  • double & aUpper[] is a buffer with calculated values of the upper line;
  • double & aLower[] is a buffer with calculated values of the lower line.

Additional methods:

  • int BarsRequired returns the minimal number of bars required for the indicator calculation;
  • string Name() returns a string with the indicator name.

The Test_BandsOnArrayArray.mq5 is an indicator demonstrating how to use the class. The IncBandsOnArray must be located in the MQL5\Include\IncOnArray directory of the terminal data folder (the IncOnArray must be created). The CMAOnArray class for the IncMAOnArray file is required for this class for work.

Bollinger Bands ® Technical Indicator (BB) is similar to Envelopes. The only difference is that the bands of Envelopes are plotted a fixed distance (%) away from the moving average, while the Bollinger Bands are plotted a certain number of standard deviations away from it. Standard deviation is a measure of volatility, therefore Bollinger Bands adjust themselves to the market conditions. When the markets become more volatile, the bands widen and they contract during less volatile periods.

An example of using the CBandsOnArray class

Translated from Russian by MetaQuotes Software Corp.
Original code:

IncIchimokuOnArray IncIchimokuOnArray

The CIchimokuOnArray class is intended for calculation of Ichimoku (Ichimoku Kinko Hyo) values on indicator buffers.

IncStdDevOnArray IncStdDevOnArray

CStdDevOnArray class is designed for calculation of Standard Deviation (StdDev) on indicator buffers. The example of use of the class is provided.

SilverTrend_HTF_Signal SilverTrend_HTF_Signal

SilverTrend_HTF_Signal shows a trend direction or a signal for performing a deal generated by SilverTrend_Signal indicator as a graphic object with colored trend indication or deal direction.

Rabbit Rabbit

Modified version of "Rabbit" indicator having enhanced display features (the indicator displays actual support/resistance levels for any currency pair).