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.26 10:43

IncOsMAOnArray - library for MetaTrader 5

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

votes: 15


COsMAOnArray class is designed for calculation of OsMA (Moving Average of Oscillator) values on indicator buffers.


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

  • int aFastPeriod - fast МА period;
  • int aSlowPeriod - slow МА period;
  • int aSignalPeriod - signal line period.
  • ENUM_MA_METHOD aFastMethod - fast МА method;
  • ENUM_MA_METHOD aSlowMetod - slow МА period;
  • ENUM_MA_METHOD aSignalMethod - signal line method.

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 aData[] - the buffer with the data for the indicator calculation;
  • double aFastMA[] - intermediate buffer for fast МА;
  • double aSlowMA[] - intermediate buffer for slow МА;
  • double aMain[] - intermediate buffer for MACD main line;
  • double aSignal[] - intermediate buffer for MACD signal line;
  • double aOsMA[] - OsMA calculated value.
Additional methods:
  • int BarsRequiredSignal() - returns the minimum number of bars for signal line calculation;
  • string Name() - returns the line with the indicator name;
  • string Names() - returns the line with the МА names.

Test_OsMAOnArray.mq5 is a sample indicator showing COsMAOnArray class application. IncOsMAOnArray 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.

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