Because you are asking the wrong question. Plot this and it will help you see 
why.

A1= HHVBars(C,50); // returns # bars
bs = HHV(C,50); // returns a value
A2=BarsSince(bs == C); // barssince C == high of C
printf("A1=" + NumToStr(A1, 1) + ", A2=" + NumToStr(A2, 1));
Plot(bs, "HHV", colorRed);
Plot(C, "c", colorBlue);
Plot(a1, "A1", colorGreen, styleOwnScale);

HHVBars is the number of bars since C was high.
HHV tells you the value of C when it was high.
The interesting thing is BarsSince C == HHV(C,50) is one less than the value 
HHVBars returns. It has to do with bar index but I would expect them to return 
the same value.

Barry

--- In [email protected], "steve_almond" <m...@...> wrote:
>
> I was trying to calculate the number of bars since the HHV of price over the 
> past 6 months (126 trading days).
> 
> This seems to work: 
> A1= HHVBars(C,126);
> 
> This doesn't seem to work: 
> A2=BarsSince(HHV(C,126));
> It always returns zero.
> 
> Why doesn't the second expression work?
> 
> Thanks,
> 
> Steve
>


Reply via email to