# 求助各位老师：EMA和STD函数在MQL5怎样实现？

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);
}
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
• 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:

EMA：

Hung Wen Lin: