MetaTrader 5 / ライブラリ

MovingAverages - MetaTrader 5のためのライブラリ

5613
(53)

移動平均のライブラリーは、 MetaTrader 5のクライアントターミナルに標準搭載されています。

このライブラリには、様々な種類の 移動平均が入っています。合計で8つあり、大きく2つの関数グループに分かれています。

最初のグループには、特定の場合における移動平均の単純な値や配列を返す関数が入っています。:

これらの関数は、一度だけ平均値を得ることを意図しています。瞬間的に何度も呼び出されることは意図されていません。ループ処理でこれらのグループの関数が必要な場合(平均値の値を計算する場合や配列を利用する場合)、最適化されたアルゴリズムを使う必要があります。

2番目の関数グループは、初期値の配列に基づいた移動平均の値によって、配列処理を受け取るように設計されています。:

  • SimpleMAOnBuffer() - price[]配列の単純平均の値で、配列buffer[]の出力を満たす。;
  • ExponentialMAOnBuffer() - price[]配列の指数平均の値で、配列buffer[]の出力を満たす。;
  • SmoothedMAOnBuffer() - price[]配列の平滑平均の値で、配列buffer[]の出力を満たす。;
  • LinearWeightedMAOnBuffer() - price[]配列の加重平均の値で、配列buffer[]の出力を満たす。

Functions:

//+------------------------------------------------------------------+ //|                                               MovingAverages.mqh | //|                        Copyright 2009, MetaQuotes Software Corp. | //|                                              https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "2009, MetaQuotes Software Corp." #property link      "https://www.mql5.com" //+------------------------------------------------------------------+ //| Simple Moving Average                                            | //+------------------------------------------------------------------+ double SimpleMA(const int position,const int period,const double &price[]) //+------------------------------------------------------------------+ //| Exponential Moving Average                                       | //+------------------------------------------------------------------+ double ExponentialMA(const int position,const int period,const double prev_value,const double &price[]) //+------------------------------------------------------------------+ //| Smoothed Moving Average                                          | //+------------------------------------------------------------------+ double SmoothedMA(const int position,const int period,const double prev_value,const double &price[]) //+------------------------------------------------------------------+ //| Linear Weighted Moving Average                                   | //+------------------------------------------------------------------+ double LinearWeightedMA(const int position,const int period,const double &price[])  //+------------------------------------------------------------------+ //| Simple moving average on price array                             | //+------------------------------------------------------------------+ int SimpleMAOnBuffer(const int rates_total,const int prev_calculated,const int begin, //+------------------------------------------------------------------+ //| Exponential moving average on price array                       | //+------------------------------------------------------------------+ int ExponentialMAOnBuffer(const int rates_total,const int prev_calculated,const int begin,                           const int period,const double& price[],double& buffer[]) //+------------------------------------------------------------------+ //| Smoothed moving average on price array                           | //+------------------------------------------------------------------+ int SmoothedMAOnBuffer(const int rates_total,const int prev_calculated,const int begin,                        const int period,const double& price[],double& buffer[]) //+------------------------------------------------------------------+ //| Linear Weighted moving average on price array                   | //+------------------------------------------------------------------+ int LinearWeightedMAOnBuffer(const int rates_total,const int prev_calculated,const int begin,                              const int period,const double& price[],double& buffer[]) 

例:

活用例"MQL5: Create Your Own Indicator"

MetaQuotes Ltdによってロシア語から翻訳されました。
元のコード: https://www.mql5.com/ru/code/77