Mql5 difference in moving average results between indicator and price closings

 
double      MA[];                // array for the indicator iMA
int         MA_handle;           // handle of the indicator iMA
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //--- creation of the indicator iMA
   MA_handle=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE);
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   //--- filling an array MA[] with current values of iMA
   //--- Copying 100 elements
   //(indicatore,buffer,0,shift+1,array)
   CopyBuffer(MA_handle,0,0,100,MA);
   //--- set indexing of elements as series, as in MQL4
   ArraySetAsSeries(MA,true);  

      
      double calculated_moving_average=(iClose(Symbol(),NULL,1)+
                                       iClose(Symbol(),NULL,2)+
                                       iClose(Symbol(),NULL,3)+
                                       iClose(Symbol(),NULL,4)+
                                       iClose(Symbol(),NULL,5))/5;
                                       
      
      Print(" moving_average             ",MA[1]);
      Print(" calculated_moving_average  ",calculated_moving_average);
    
      
   }

why are there computational differences in the following code?

 
SergioTForex: why are there computational differences in the following code?

In the preceding code, you compute a five (5) period simple (SMA) and compare that to a five (5) period exponential (EMA). Why would you think they would ever be the same?

 

sorry, I only realized the mistake now

Reason: