Use of Indicator inside an EA gives wrong data. Please help - page 2

 
alg2013:

Printed it and value was 2 (for some strange reason). Then I set it up upfront as AvPerio=14 and when printed again, now it was 14 (correct). However, still iMAOnArray[AvPeriod] returned 0.

thanks again... 

 


I don't have and don't know what kind of  indicator "SNR1IND" is. 

And so most who read this topic.  I have to guess what might be wrong or what you think it is wrong working

What about
double AvExpoArrayvalueo=iMAOnArray(SNR1_buffer,0,AvPeriod,0,MODE_EMA,0);
double AvExpoArrayvalue1=iMAOnArray(SNR1_buffer,0,AvPeriod,0,MODE_EMA,1);
double AvExpoArrayvalue2=iMAOnArray(SNR1_buffer,0,AvPeriod,0,MODE_EMA,2);


Print("AvExpoArrayvalueo   =   ",DoubleToStr(AvExpoArrayvalueo,Digits),"\n AvExpoArrayvalue1   =   ",DoubleToStr(AvExpoArrayvalue1,Digits),
"\n AvExpoArrayvalue2   =   ",DoubleToStr(AvExpoArrayvalue2,Digits));
Do they give other output .....
 
alg2013:

Printed it and value was 2 (for some strange reason). Then I set it up upfront as AvPerio=14 and when printed again, now it was 14 (correct). However, still iMAOnArray[AvPeriod] returned 0.

You only populated PeriodSNR values in the SNR1_buffer. For a EMA you need at least 3.45 * (AvPeriod+1) values to get a EMA.
 

Thanks deVries again

Used your nice code to check and yet again the values returned were all -0.00000.

Trying to think: The actual array SNR1_Buffer[] in the following code does contain data, so the problem is not the creation of the buffer to feed into the iMAOnArray function

for(i=0; i<limit; i++)
      {
      SNR1_buffer[i]=iCustom(NULL,0,"SNR1IND",0,i);
      }

 However, the iMAONArray function still returns 0 (as -0.00000).

I dont really understand this function. I replaced the iMAOnArray short code by a quick code for a SMA using the data in the SNR1_Buffer[i] and no problem, it returned values. so it must be the way the SNR1_buffer data is handled (if at all!) by the iMAOnArray function what is wrong.

 

Thanks WHRoeder

I know, and when I changed the period value to 14, did not show up anny better results. 

 
alg2013: I know, and when I changed the period value to 14, did not show up anny better results.
What does that have to do with what I posted? If you want a 14 period EMA you need 52 values. Fix your limits.
Reason: