거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
지표

The class for drawing the OsCD using the ring buffer - MetaTrader 5용 지표

조회수:
4663
평가:
(20)
게시됨:
2013.01.07 15:45
업데이트됨:
2016.11.22 07:32
\MQL5\Include\IncOnRingBuffer\ \MQL5\Indicators\IncOnRingBuffer\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

Description

The COsMAOnRingBuffer class is designed to calculate the technical indicator Moving Average of Oscillator (Moving Average of Oscillator, OsMA) using the algorithm of the ring buffer

Declaration

class COsMAOnRingBuffer : public CArrayRing

Title

#include <IncOnRingBuffer\COsMAOnRingBuffer.mqh>

File of the COsMAOnRingBuffer.mqh class should be placed in the IncOnRingBuffer folder that need to be established in MQL5\Include\. Two files with the examples used by the class from this folder are attached to the description. File with the ring buffer, the MACD and Moving Average classes also should be in this folder.

Class methods

//--- initialization method:
bool Init(                                  // if error it returns false, if successful - true
   int            fast_period   = 12,       // the period of fast Moving Average smoothing 
   int            slow_period   = 26,       // the period of slow Moving Average smoothing 
   int            signal_period = 9,        // the period of signal Moving Average smoothing 
   ENUM_MA_METHOD fast_method   = MODE_EMA, // the method of fast Moving Average smoothing
   ENUM_MA_METHOD slow_method   = MODE_EMA, // the method of slow Moving Average smoothing
   ENUM_MA_METHOD signal_method = MODE_SMA, // the method of signal Moving Average smoothing
   int            size_buffer   = 256,      // the size of the ring buffer, the number of stored data
   bool           as_series     = false     // true, if a time series, false if a usual indexing of the input data
   );
//--- the method of calculation based on a time series or indicator buffer:          
int MainOnArray(                  // returns the number of processed elements  
   const int     rates_total,     // the size of the array array[]
   const int     prev_calculated, // processed elements on the previous call
   const double &array[]          // the array of the input values
   );
//--- the method of calculation based on the separate series elements of the array           
double MainOnValue(              // returns the OsMA  value for the set element
   const int    rates_total,     // the size of the array
   const int    prev_calculated, // processed elements of the array
   const int    begin,           // from where the significant data of the array starts
   const double value,           // significant elements of the array
   const int    index            // the element index
   );
//--- the methods to access to data:
int    BarsRequired();   // Returns the necessary number of bars for drawing the indicator
string Name()            // Returns the name of the indicator
string FastMethod()      // Returns the method of smoothing of the fast line in the form of the text line
string SlowMethod()      // Returns the method of smoothing of the slow line in the form of the text line
string SignalMethod()    // Returns the method of smoothong of the signal line in the form of the text line
int    FastPeriod()      // Returns the period of smoothing of the fast line
int    SlowPeriod()      // Returns the period of smoothing the slow line
int    SignalPeriod()    // Returns the period smoothing of signal line
int    Size();           // Returns the size of the ring buffer

To get the calculated data of the indicator from the ring buffer is possible as from the usual array. For example:

//--- the class with the methods of the indicator calculation OsMA:
#include <IncOnRingBuffer\COsMAOnRingBuffer.mqh>
COsMAOnRingBuffer osma;

...

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int    rates_total, 
                const int    prev_calculated, 
                const int    begin, 
                const double &price[]) 
  {
//--- the calculation of the indicator based on a price time series:
   osma.MainOnArray(rates_total,prev_calculated,price);

...

//--- use the data from the "osma" ring buffers,
//    copy the data in the indicator buffer:
   for(int i=start;i<rates_total;i++)
      OsMABuffer[i]=osma[rates_total-1-i];          // indicator histogram
//--- return value of prev_calculated for next call:
   return(rates_total);
  }

Please note that indexing in the ring buffer is the same as in the time series.

Examples

  1. The Test_OsMA_OnArrayRB.mq5 file calculates the indicator based on price time series. The MainOnArray() method application is demonstrated
  2. The Test_OsMA_OnValueRB.mq5 file demonstrates the use of the MainOnValue() method. At first the OsMA indicator is calculated and drawn. Then on the basis of this ring buffer of this indicator one more OsMA indicator is drawn. 


The result of the work of the Test_OsMA_OnArrayRB.mq5 with the size of the ring buffer of 256 elements.



The result of the work of the Test_OsMA_OnValueRB.mq5 with the size of the ring buffer of 256 elements.

 

When writing code the developments of MetaQuotes Software Corp.Integer and GODZILLA were used.

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/1367

Exp_VininI_Trend Exp_VininI_Trend

The Exp_VininI_Trend trading system is based on change of the trend direction displayed by the VininI_Trend indicator.

XMA_TrendSignal XMA_TrendSignal

The indicator that fixes three states of the market.

The class for drawing the Stochastic using the ring buffer The class for drawing the Stochastic using the ring buffer

The class is designed for calculation the technical indicator Stochastic Oscillator (Stochastic Oscillator) using the algorithm of the ring buffer.

ytg_Japan_Candles ytg_Japan_Candles

The indicator of the candlesticks combinations (Japanese candlesticks)