Position index 1 is out of bounds.

Questions about MultiCharts and user contributed studies.
shanoballs
Posts: 12
Joined: 28 Aug 2006
Contact:

Position index 1 is out of bounds.

Postby shanoballs » 23 Dec 2006

I'm trying to make a strategy that will generate random trade signals for me, but after compiling the code and applying it to the chart, i get an error saying that "Position index 1 is out of bounds", what is this referring to? the strategy code is as follows:

Code: Select all

variables:
MP(0),
Trigger(0);

MP = marketposition(0);
Trigger = Random(15);

if totaltrades = 0 then buy this bar;

if (barssinceexit(1) > 20) and (totaltrades < 32) then
begin
if (Trigger > 8) then buy this bar on close;
end;

if (MP = 1) and barssinceentry(0) >= 10 then sell this bar on Close;

what i want is Multicharts to pick a number between 1 and 15 and if that number is greater than 8 i want it to buy and keep that buy for 10 bars and then exit. and i also want Multicharts to only take a total of 32 trades and have at least 20 bars in between the exit of one trade and the entry of the next. any idea why I'm getting this error?

any help is appreciated,

shane

attached is the screen shot of the error.
Attachments
error1.JPG
(12.43 KiB) Downloaded 874 times

User avatar
Kate
Posts: 758
Joined: 08 Dec 2006

Postby Kate » 25 Dec 2006

Shanoballs,

In our opinion such TS reserved words as BarsSinceEnrty are implemented improperly so that they store values for the last ten elements and return zeros even if the array is empty. So far in MultiCharts if a user applies such functions and receives "Position index 1 is out of bounds" it means that the array is empty and he refers the array elements before they are received.

But due to the users' complaints we have changed these functions so that they will be working as in TS and return values.

shanoballs
Posts: 12
Joined: 28 Aug 2006
Contact:

Postby shanoballs » 25 Dec 2006

Shanoballs,

In our opinion such TS reserved words as BarsSinceEnrty are implemented improperly so that they store values for the last ten elements and return zeros even if the array is empty. So far in MultiCharts if a user applies such functions and receives "Position index 1 is out of bounds" it means that the array is empty and he refers the array elements before they are received.

But due to the users' complaints we have changed these functions so that they will be working as in TS and return values.
Thanks for the response, so are you saying that they are changed to work in the current beta? or are you saying that they WILL be implemented to work? I'm sorry but I'm having trouble understanding what you're saying.

shane

User avatar
Kate
Posts: 758
Joined: 08 Dec 2006

Postby Kate » 25 Dec 2006

I mean that we are preparing a new version where these functions will work as in TS and return values. In the current beta if you use these functions and if the array is empty you will receive "Position index 1 is out of bounds" message.

shanoballs
Posts: 12
Joined: 28 Aug 2006
Contact:

Postby shanoballs » 26 Dec 2006

I mean that we are preparing a new version where these functions will work as in TS and return values. In the current beta if you use these functions and if the array is empty you will receive "Position index 1 is out of bounds" message.
Thank you for the clarification, looking forward to the next version.

shane

Guest

Postby Guest » 26 Dec 2006

Thanks for making this change. I am also looking forward to the next version.

momentum
Posts: 324
Joined: 23 Nov 2005
Has thanked: 9 times
Been thanked: 14 times

Postby momentum » 01 Jan 2007

Kate, can u pls advise if the TS compatible beta will be out svery soon as I need to know whether its worth changing existing studies/strategies.

Thanks

User avatar
Stanley Miller
Posts: 556
Joined: 26 Jul 2005
Has thanked: 3 times

Postby Stanley Miller » 02 Jan 2007

Kate, can u pls advise if the TS compatible beta will be out svery soon as I need to know whether its worth changing existing studies/strategies.

Thanks
It will be released within a week.


Return to “MultiCharts”