Index was out of range
Author: Musashi1970
Creation Date: 1/12/2010 1:05 PM
profile picture

Musashi1970

#1
Hi

1.
why get I an error message when I use this command:
if ( SMA.Value(bar, Close, 20) > SMA.Value(bar, Close, 100) )
{...

when I use:
if (SMA.Series(Close,20)[bar] > SMA.Series(Close,100)[bar])
{...
it works.

2. The error messages which I get e.g. in the above case are in bad translated german. what is the reason for this (probably some Microsoft issue?) and more important is it possible to change this, so I would get the error messages in english ?

Thx

Kind Regards
profile picture

Eugene

#2
Hi,
QUOTE:
why get I an error message when I use this command:

It's quite hard to tell, given that we neither have the message nor the rest of the code etc.
QUOTE:
and more important is it possible to change this, so I would get the error messages in english ?

Yes, switch to a English operating system (LCID 1033 or alike). These messages are generated by the C# compiler in .NET, not Wealth-Lab, so .NET automatically chooses your "mother tongue".
profile picture

Musashi1970

#3
ok. complete code:

CODE:
Please log in to see this code.

error message (my translation):
index out of bounds. it must not be negative or smaller than the register (?)

QUOTE:
switch to a English operating system

so, I would have to purchase Win 7 in an english version or is it possible to install an english .NET on a german Win 7 ?

Thx
profile picture

Eugene

#4
Thank you.

Here's what our WL5 Wiki knows about > Index was out of range.

And here's the mistake:
CODE:
Please log in to see this code.

According to Wiki, it's case #1: you're accessing the data at an invalid bar number. Your trading loop starts at bar 50, and you call the .Value at bar 100.

Solution: start your trading loop from bar 100. Even better idea would be to define the SMA DataSeries before the loop, and then start the loop from DataSeries.FirstValidValue (QuickRef for more). Example:
CODE:
Please log in to see this code.


QUOTE:
so, I would have to purchase Win 7 in an english version or is it possible to install an english .NET on a german Win 7 ?

Based on experience, I don't think installing an English .NET on a localized Windows will make .NET speak English when presenting you with error/exception messages.
profile picture

Musashi1970

#5


Well... the error is obvious now and as a matter of fact, I am well aware of that easy to understand rule from my experience with WLD 4.
Sorry, obviously sometimes I am not that concentrated when I work with WLD after a long office day ;-)

In any case, thank you very much.

Kind Regards
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).