Thanks, that helped a lot.  Barry

--- In [email protected], "zdomokos" <zdomo...@...> wrote:
>
> Barry,
> I really recommend to read this article:
> http://www.amibroker.com/kb/2008/07/03/quickafl/
> 
> this line does the same thing as your for loop, but you need to be
> aware that BarCount is changing as it explained in the above referenced 
> article. 
> 
> Plot(HHV(C,BarCount),"a",colorRed);
> 
> Zsolt
> 
> --- In [email protected], "Barry" <razzbarry@> wrote:
> >
> > I am not new to Ami, been using it since 2003.  But at times the array 
> > processing drives me nuts.  I tried to use barssince and looked at the buy 
> > and sell arrays before they were set. so they were still nulls even when I 
> > initialized them to buy = sell = 0;
> > 
> > But to try to understand what the arrays were doing I wrote a stupid little 
> > program to see what was going on. The code is below.
> > 
> > What I am trying to do is save the highest hi in an array called theHi.  I 
> > set the first cell in theHi to the value of in the first cell of the close. 
> >  Then I compare them but theHi follows the close even when the close goes 
> > down.
> > 
> > Then I wrote the same function in a for loop and it works fine.  
> > 
> > Then I added the formula to Excel and it worked correctly.  
> > =IF(C3>D2,C3,D2) where C has the close and D the hi array values. Here I 
> > also set the hi in cell 2 to the first value of Close.
> > SO excel works fine with the same formula as Afl but Afl fails.
> > 
> > I must be missing something really basic. Can anyone tell me why Ami won't 
> > allow me to scan through the close array and save the high?
> > 
> > Thanks,
> > Barry
> > 
> > _SECTION_BEGIN("TestBarsSince");
> > 
> > _N(Title = StrFormat("BarsSince test - {{INTERVAL}} {{DATE}} \nOpen %g, Hi 
> > %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, 
> > H, L, C, SelectedValue( ROC( C, 1 )) ));
> > 
> > Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | styleBar 
> >  ); // shows all style options
> > 
> > theHi[0] = C[0];
> > theHi = IIf(C > Ref(theHi, -1), C, Ref(theHi, -1));
> > Plot(theHi, "\nTheHi", colorBlue  );
> > 
> > forHi[0] = C[0];
> > for (i = 1; i < BarCount; ++i)
> > {
> >     if(C[i] > forHi[i-1]) forHi[i] = C[i]; else forHi[i] = forHi[i-1];
> > }
> > 
> > Plot(forHi, "\nHi with for loop", colorGreen);
> > 
> > _SECTION_END();
> >
>


Reply via email to