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

Re: [amibroker] Re: New file uploaded to amibroker



PureBytes Links

Trading Reference Links

HI;
 
YOU SHOULD CODE
 
if( !(BarCount >= 10) )
{

..... put code that assumes that you have 10 data points available here.

}
instead!

Regards,
 
Udo

"Tomasz Janeczko (groups)" <groups@xxxxxxxxxxxxx> wrote:
Hello,

You must not assume that you have some fixed number of
data elements available. *Always* perform a check for BarCount.

So instead of:

for (i = 0; i < 10; i++) myArr[i] = 0;

always include check:

for (i = 0; i < 10 AND i < BarCount; i++) myArr[i] = 0;

alternatively:

if( BarCount >= 10 )
{

..... put code that assumes that you have 10 data points available here.

}

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "gp_sydney" <gp.investment@gmail.com>
To: <amibroker@xxxxxxxxxps.com>
Sent: Saturday, June 16, 2007 2:08 AM
Subject: [amibroker] Re: New file uploaded to amibroker

> > I still do not understand what the difference between the size of an
> > array and the number of elements in an array is.
>
> They are the same, but when you have a loop writing only 10 elements
> to an array, that's not how many elements are in the array, it's only
> the number of elements you've changed. The array might have 1000
> elements and all you've done is overwrite the first 10.
>
> The size of an array is how many elements it's physically possible to
> change because there's actually memory allocated for their storage. In
> AmiBroker that's always BarCount.
>
> As I sort-of mentioned before, using arrays where the index is
> something other than bars, and you fix the range of the index to
> something other than BarCount, can easily lead to problems. If you
> have such a formula in a backtest and run that across all symbols, the
> moment you hit a symbol where BarCount is less than the maximum index
> you use, you'll get an overflow error.
>
> For example, if you have the following code in a backtest:
>
> for (i = 0; i < 10; i++) myArr[i] = 0;
>
> and run it over all symbols, if you hit a new listing that only has
> five bars on the chart then you'll get an overflow error when myArr[5]
> is referenced for that symbol.
>
> Regards,
> GP
>
>
>
>
> 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
> Yahoo! Groups Links
>
>
>
>
>

__._,_.___

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___