Doubt on accesing indicator previous values!! Anyone can help?

Posted By: Oligon

Doubt on accesing indicator previous values!! Anyone can help? - 10/23/17 19:05

Hello everyone!

I'm very excited to try Zorro, however I'm having some trouble to figure out how can I access previous values of the ZigZag indicator. For example if I want to get the rPeak value but 2 values before the current value, how would I approach it? I know rPeak is a global var type, but how can I access for example rPeak(2)?

Thanks so much in advance for anyone that could point me in the right direction!!
Posted By: Dalla

Re: Doubt on accesing indicator previous values!! Anyone can help? - 10/24/17 06:39

Try rPeak[2]
Posted By: jcl

Re: Doubt on accesing indicator previous values!! Anyone can help? - 10/24/17 07:31

For getting old rPeak values, store them when a new peak appears, i.e. when rPeak becomes smaller.

Code:
static int Peak1 = 99999, Peak2, Peak3;

ZigZag(....);
if(rPeak < Peak1) {
  Peak3 = Peak2+1;
  Peak2 = Peak1+1;
  Peak1 = rPeak;
} else {
  Peak3++;
  Peak2++;
  Peak1++;
}




Posted By: Oligon

Re: Doubt on accesing indicator previous values!! Anyone can help? - 10/24/17 20:37

Thank you so much!!
Posted By: Oligon

Re: Doubt on accesing indicator previous values!! Anyone can help? - 10/24/17 20:37

Thanks JCL! Will try that!
© 2024 lite-C Forums