PureBytes Links
Trading Reference Links
|
Hi - I think you have run into the old "recursive" problem. In the first
line...
theHi[0] = C[0];
you set only the first bar of the Hi to the close. Don't know what the rest
of the array is offhand, AB may initialize it to zero or null or something,
otherwise I would think the values are whatever was previously in memory.
Then the second line operates on the entire array at once so it will use
whatever those values of theHi are at that point, it will *not* do one bar
at a time and then refer back to that bar, I think that is one reason why TJ
added looping.
It looks like you are looking for the highest Close in the array, could you
just use
Highest( Close) ?
Steve
----- Original Message -----
From: "Barry" <razzbarry@xxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Monday, September 21, 2009 5:25 PM
Subject: [amibroker] Help understanding array processing
>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
>
>
>
>
------------------------------------
**** 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/
|