Moving Average value is not correct with chart value

 

Hallo,

I dont understand what is wrong this :

Here you can see actual value in comment but its different than value of MA-line on chart :(

Moving Average Test


void OnTick() 
{
 Comment ("Linear MA = ",MA_Linear(),"    ","Exponential MA = ",MA_Exponential());    
}

double MA_Linear()
{
   double MA_Linear_Array [];
   int    MA_Linear_Definition = iMA (_Symbol, MA_Linear_Period, MA_Linear_Num, 0, MODE_LWMA, PRICE_MEDIAN);
   
      ArraySetAsSeries  (MA_Linear_Array, true);
      CopyBuffer        (MA_Linear_Definition, 0, 0, 1,MA_Linear_Array);
      
   double MA_Linear_Value = NormalizeDouble (MA_Linear_Array [0], 3);
   return MA_Linear_Value;
}
//+------------------------------------------------------------------+
double MA_Exponential()
{
   double MA_Exponential_Array [];
   int    MA_Exponential_Definition = iMA (_Symbol, MA_Exponential_Period, MA_Exponential_Num, 0, MODE_EMA, PRICE_CLOSE);
   
      ArraySetAsSeries  (MA_Exponential_Array, true);
      CopyBuffer        (MA_Exponential_Definition, 0, 0, 1,MA_Exponential_Array);
      
   double MA_Exponential_Value = NormalizeDouble (MA_Exponential_Array [0], 3);
   return MA_Exponential_Value;
}
//+------------------------------------------------------------------+
 

MA-line on chart? Could it be due to not having ?: IndicatorDigits(Digits);

 

You're probably calling for the wrong timeframe. 

iMA (_Symbol, MA_Exponential_Period, MA_Exponential_Num, 0, MODE_EMA, PRICE_CLOSE);

Try this instead.

iMA(_Symbol, _Period, MA_Exponential_Num, 0, MODE_EMA, PRICE_CLOSE);
 
nicholi shen:

You're probably calling for the wrong timeframe. 

Try this instead.

Im so stupid :D thanks it works now 

Reason: