求助各位老师:EMA和STD函数在MQL5怎样实现?

xdwz  
我是初学者,其他软件中的EMA(C,10)、STD(C,10)在MQL5中怎么写?请指点,谢谢。
Ziheng Zhuang  

在Include文件夹中有个MovingAverages.mqh,移动平均的算法都有。

EMA:

//+------------------------------------------------------------------+
//| Exponential Moving Average                                       |
//+------------------------------------------------------------------+
double ExponentialMA(const int position,const int period,const double prev_value,const double &price[])
  {
//---
   double result=0.0;
//--- calculate value
   if(period>0)
     {
      double pr=2.0/(period+1.0);
      result=price[position]*pr+prev_value*(1-pr);
     }
//---
   return(result);
  }

STD,参考 https://www.mql5.com/en/code/18330

double GetStdDev(const double &arr[],int size)
{
    if(size<2)return(0.0);
    
    double sum = 0.0;
    for(int i=0;i<size;i++)
    {
      sum = sum + arr[i];
    }
        
      sum = sum/size;    
    
    double sum2 = 0.0;
    for(int i=0;i<size;i++)
    {
      sum2 = sum2 + (arr[i]- sum) * (arr[i]- sum);
    }  
      
      sum2 = sum2/(size-1);      
      sum2 = MathSqrt(sum2);
      
      return(sum2);
}
Standard Deviation Channel MT5
Standard Deviation Channel MT5
  • www.mql5.com
Colored Zerolag MACD It is the MQL5 version of ZeroLag MACD. MetaCOT 2 CFTC ToolBox (Set of Indicators) MT5 MetaCOT 2 CFTC ToolBox Indicators is a set of MetaCOT 2 indicators that provide access to CFTC reports. MetaCOT 2 supports...
Ziheng Zhuang  
Hung Wen Lin:
看幫助文件 裏面有教如何使用


在帮助文档中哪个章节有MovingAverages.mqh的使用介绍?

截个图看看。

原因: