mql4, array and standard deviation

 

Hello guys; I need a little help about this issue. I would like to create an EMA "dynamic", where the parameter "pr" changes; in fact here you are the script. The script is a "standard script" for an EMA plus two arrays; one is a collection of price close, the other the collection af an EMA. Thus, I calculate the ratio between the standard deviation of every arrays. 

Can you verify if I'm correctly using the iStdDevOnArray(..) function to calculate the standard deviation?

Best regards and thank you.

Bruno

 

void ema()

  {

   double pr=2.0/(MA_Period+1);

   int    pos=Bars-2;

   int i;

   double sigma_array_ema[100];

   double sigma_array_price[100];

   ArraySetAsSeries(sigma_array_ema,true);

   ArraySetAsSeries(sigma_array_price,true);

  if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;

//---- main calculation loop

   while(pos>=0)

     {

       ExtMapBuffer[pos]=Close[pos]*pr+ExtMapBuffer[pos+1]*(1-pr);

      for(i=0; i<100;i++)

      sigma_array_ema[i]=iMA(NULL,0,MA_Period,0,MODE_EMA,PRICE_CLOSE,i);

      for(i=0; i<100;i++)

      sigma_array_price[i]=Close[i];

      pr=iStdDevOnArray(sigma_array_ema,100,PERIOD_STDDEV,0,MODE_EMA,0)/iStdDevOnArray(sigma_array_price,100,PERIOD_STDDEV,0,MODE_EMA,0);

      pos--;

     }

  } 
 
Thank you.
 
RaptorUK:
Thank you.

I'm sorry; thank you.