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

Re: [amibroker] Re: Subscript out of range - why?



PureBytes Links

Trading Reference Links

Hello,

Simply your data must have ONLY ONE BAR - that's the reason.

You must access array elements from 0 upto (BarCount-1).
If BarCount is 1 then the only available element is element 0.

Correct code would be:

f[0]=0;
if( BarCount > 1 ) f[1]=0;
Filter=1;
NumColumns=1;


Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "giggollo99" <giggollo@xxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, March 31, 2005 10:30 AM
Subject: [amibroker] Re: Subscript out of range - why?


> 
> 
> Thanks kavemanperth for your reply. Here is my full code:
> 
> f[0]=0;
> //f[1]=0;
> Filter=1;
> NumColumns=1;
> 
> I have nothing else in my AA window except the above 4 lines of code
> (try it). If i uncomment the second line i get an "Subscript out of
> range" error in that second line when i run an exploration. I know the
> code is not doing anything useful, im trying to isolate the problem,
> and understand why i cant index the second element of array "f". 
> 
> Thanks in advance,
> g
> 
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxxx> wrote:
>> the error is not actually in the lines you have quoted
>> most likely it comes from a couple of areas, either the first bar or
> last 
>> bar of the loop is outside the actualbars in the database
>> 
>> an example
>> if you reference a previous bar in the loop, eg f[i-1] then the for 
>> statement must read
>> *for(i=1;i<barcount;i++)*
>> I also assume you reference 2 previous bars as you have f[0] and
> f[1] 
>> identified so the for line should be starting at the 3rd bar
>> *for(i=2;i<barcount;i++)*
>> 
>> the last bar in the chart is specified by Barcount, but this is the
> total 
>> number of bars, not the final bar barindex. Lastvalue(barindex()) = 
>> Barcount-1
>> If you are using <= then use 
>> *for(i=2;i<=barcount-1;i++)*
>>  Hope I ahve understood correctly and have helped a bit
>>     
>> On Mar 31, 2005 2:29 PM, giggollo99 <giggollo@xxxx> wrote:
>> > 
>> > 
>> > Hi all,
>> > 
>> > I am getting a "Subscript out of range..You must not access array
>> > elements outside 0..(BarCount-1) range" error when i write the
>> > following two lines of code:
>> > 
>> > f[0]=0; // no error on this line
>> > f[1]=0; // error occurs on this line !
>> > 
>> > I don't understand why this is happening. When i check the value
> of
>> > Barcount in Commentary window, i see "256". So 1 is within the
> range
>> > of 0..barcount-1 (i.e. 0..255). Why do i get an error here?
>> > 
>> > Thanks in advance
>> > g
>> > 
>> > 
>> > Please note that this group is for discussion between users only.
>> > 
>> > To get support from AmiBroker please send an e-mail directly to
>> > SUPPORT {at} amibroker.com <http://amibroker.com>
>> > 
>> > For other support material please check also:
>> > http://www.amibroker.com/support.html
>> > 
>> > 
>> > Yahoo! Groups Links
>> > 
>> > 
>> > 
>> > 
>> > 
>> 
>> 
>> -- 
>> Cheers
>> Graham
>> http://e-wire.net.au/~eb_kavan/
> 
> 
> 
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

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

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