Calculate Z-score and take iMa of it (smoothing)

Back to topics list To post a new topic, please log in or register
avatar
8
Synthacon 2016.01.13 22:27
 

Hi there,

I'm trying to calculate MA of Z-score. Z-Score calculation works fine but I can't get any value out of iMa. Any suggestions?

Cheers!

double GetZ(int bar)
   { 
  
  double z_score[];
   
  //Calculate Z-score
  z_score[bar] = ((iClose(NULL, PERIOD_CURRENT, bar) -
              iMA(NULL,PERIOD_CURRENT,Period_Z,0,Smoothing_Method,Price,bar))/
          iStdDev(NULL,PERIOD_CURRENT,Period_Z,0,Smoothing_Method,Price,bar));
          
 
  //Smooth z-score
  return(iMA(NULL,PERIOD_CURRENT,10,0,0,z_score[bar],bar));
          
 } 
avatar
Moderator
3404
GumRai 2016.01.13 22:45 #
 
double z_score[];

You don't size the array

Do you even need the array?

 

return(iMA(NULL,PERIOD_CURRENT,10,0,0,z_score[bar],bar));

Why are you using the value in the array as the applied price in the  iMA call?

avatar
8
Synthacon 2016.01.13 22:55 #
 
GumRai:

You don't size the array

Do you even need the array?

 

Why are you using the value in the array as the applied price in the  iMA call?

I tried without too but got some weird lines in the indicator window...

The calculated Z-score is way to "raw" I just want it to be smooth. I'm not sure how I can do that and was thinking I can achieve that using iMA.

double GetZ(int bar)
   { // Bar Close z-score
  
  double z_score;
   
  z_score = ((iClose(NULL, PERIOD_CURRENT, bar) -
              iMA(NULL,PERIOD_CURRENT,Period_Z,0,Smoothing_Method,Price,bar))/
          iStdDev(NULL,PERIOD_CURRENT,Period_Z,0,Smoothing_Method,Price,bar));
          
   
   return(iMA(NULL,PERIOD_CURRENT,10,0,0,z_score,bar));
          
 } 
avatar
Moderator
3404
GumRai 2016.01.14 01:07 #
 
double GetZ(int bar)
   { // Bar Close z-score
  
  double z_score;
   
  z_score = ((iClose(NULL, PERIOD_CURRENT, bar) -
              iMA(NULL,PERIOD_CURRENT,Period_Z,0,Smoothing_Method,Price,bar))/
          iStdDev(NULL,PERIOD_CURRENT,Period_Z,0,Smoothing_Method,Price,bar));
          
   
   return(iMA(NULL,PERIOD_CURRENT,10,0,0,z_score,bar));
          
 } 

Again, why are you using z_score as the applied price in the iMA call?

I am guessing that you probably want to do something with iMAonArray 

avatar
8
Synthacon 2016.01.14 02:21 #
 
GumRai:

Again, why are you using z_score as the applied price in the iMA call?

I am guessing that you probably want to do something with iMAonArray 

iMAOnArray solved the problem! Thank you!
void MA1_Z() //First MA of Z
{
for(int i=limit-Period1; i>=0; i--)
   {
   Buff[i]= iMAOnArray(zscore,0,Period2,0,Mode2,i);

  } 
}
void MA2_Z() //Second MA of Z
{
for(int j=limit-Period1; j>=0; j--)
   {
   MAofMA[j]= iMAOnArray(Buff,0,Period3,0,Mode3,j);
   }
}
Back to topics list  

To add comments, please log in or register