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.21 10:20

IncStochasticOnArray - library for MetaTrader 5

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

votes: 16

CStochasticOnArray class is designed for calculation of Stochastic on indicator buffers.


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

  • int STPeriodK - K period;
  • int STPeriodD - D period;
  • int STPeriodS - S period.
  • ENUM_MA_METHOD STMethod - smoothing method signal line.

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 aDataClose[] - the buffer with the data used for the indicator calculation;
  • 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 & aStochMain[] - calculated value of the main line;
  • double & aStochSignal[] - calculated value of the signal line.

Additional methods:

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

Test_StochasticOnArray.mq5 is a sample indicator showing CStochasticOnArray class usage. IncStochasticOnArray file must be placed to MQL5\Include\IncOnArray of the terminal data folder (IncOnArray folder must be created).

CMAOnArray class from the IncMAOnArray file is needed for the proper work. It can be found here.

The Stochastic Oscillator Technical Indicator compares where a security’s price closed relative to its price range over a given time period. The Stochastic Oscillator is displayed as two lines.

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

Example of MACD Automated Example of MACD Automated

Code example of MACD automated with advanced money management function.

Pivot Star Pivot Star

Pivot indicator. Standard, Fibonacci, Camarilla, Woody's, Demark. Calculates pivot points from previous bar of chosen period (M5 - MN).