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

Re: [amibroker] Re: Help understanding array processing



PureBytes Links

Trading Reference Links

Hi Barry, I believe subscripts [] will use the shorter QuickAFL arrays and 
not the entire dataset.


----- Original Message ----- 
From: "Barry" <razzbarry@xxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Monday, September 21, 2009 7:46 PM
Subject: [amibroker] Re: Help understanding array processing


> What I am trying to do is find the lowest low from the last sell so I can 
> calculate a buy point above that low, or below the high for a sell.  The 
> first problem I ran into was what to do before the first trade.  I used 
> highest and lowest but afterward I wanted to use hhv and llv.  Ami goes 
> nuts when I try to reference buy and sell before they are ever set.  So 
> barssince returned nulls for all bars.
>
> Marcin told me I had to use loops.  I remember loops really slowing things 
> down so I tried to do it another way. I tried to set my test hi and low 
> arrays one step at a time.  The hi and lo just followed the close. I was 
> expecting it to operate one bar at a time. That did not work as you 
> pointed out.
>
> I finally said to heck with it and used loops. I am used to arrays in C++ 
> and I really get screwed up with Ami's arrays. Do you know if looping 
> slows the process down a lot or does Ami only go back far enough to load 
> the indicators correctly?  I remember seeing something like that.
>
> Thanks Steve,
> Barry
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxx> wrote:
>>
>> 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@xxx>
>> 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
>
>
>
> 




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

**** 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/