[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Help understanding array processing



PureBytes Links

Trading Reference Links

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();



------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/