PureBytes Links
Trading Reference Links
|
The rule is simple:
ANY array index (subscript) is checked if it is INSIDE
0...BarCount-1 boundary.
If it is not, "subscript out of range" error is generated.
As Mike said, because of blank bars on the right hand, "lastvisiblebar"
may be greater than last array bar, therefore you need to
verify if index is < (less than) BarCount always:
if( i >= 0 && i < BarCount )
{
// ONLY UNDER THIS CONDITION you can access i-th array element)
}
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "Mike" <sfclimbers@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, May 01, 2009 8:20 PM
Subject: [amibroker] Re: Simple Question
> Very interesting problem.
>
> First, it appears that your code is not quite right. It would appear that Status("lastvisiblebar") will actually give you the
> index of the last bar *including* blank bar padding to the right of the chart.
>
> So, check your charting preference settings for "Blank bars in right margin" (via Tools | Preferences... | Charting). Following
> your logic, you would need to subtract that many bars from the result of Status("lastvisiblebar").
>
> e.g.
> lbr = Status("lastvisiblebar") - 10;
>
> However, I believe that a recent beta has added the ability to stretch the right padding even more, so this approach is probably
> not going to work in more recent versions than mine (5.20). A more reliable way would be to take the lesser of the Status result
> and BarCount - 1.
>
> e.g.
> lbr = min(Status("lastvisiblebar"), BarCount - 1);
>
> Second, it appears that when running the syntax verify, Status("lastvisiblebar") returns -1. Presumably this is because the code
> is not being run in the context of the chart. However, if you simply save the changes, your chart will correctly update to reflect
> your code.
>
> Mike
>
> --- In amibroker@xxxxxxxxxxxxxxx, "brianw468" <wild21@xxx> wrote:
>>
>> Can someone please advise where the error is in the following simple code:-
>>
>> fbr = Status("firstvisiblebar");
>> Lbr = Status("lastvisiblebar")-1;
>>
>> x0 = fbr;
>> x1 = Lbr;
>> y0 = H[fbr];
>> y1 = L[Lbr];
>> Line = LineArray(x0,y0,x1,y1);
>> Plot(Line,"Line",colorGreen);
>>
>> The compiler produces an "out of range" error for the subscript in y1.
>> Hard to see how, since the status calls should return array index values, which obviously should be within the range used.
>> Thanks.
>>
>
>
>
>
> ------------------------------------
>
> **** 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/
|