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

Re: [amibroker] Re: Error 10. Subscript out of range. You must not access array elements outside 0..


  • To: <amibroker@xxxxxxxxxxxxxxx>
  • Subject: Re: [amibroker] Re: Error 10. Subscript out of range. You must not access array elements outside 0..
  • From: "Tomasz Janeczko" <groups@xxxxxxxxxxxxx>
  • Date: Mon, 9 Mar 2009 11:55:09 +0100

PureBytes Links

Trading Reference Links

Actually b < BarCount
should be used instead of for b < BarCount-1
since "less than" operator guarantees that b is never equal to BarCount.
Alternativelly one could use b <= BarCount-1  (note less or equal operator used this time).

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "murthysuresh" <money@xxxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, March 08, 2009 10:52 PM
Subject: [amibroker] Re: Error 10. Subscript out of range. You must not access array elements outside 0..


> thanks to all for the help. i fixed it to
> for ( b = firstVisibleBar;((b < lastVisibleBar) AND (b<BarCount-1)) ;b++ )
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> wrote:
>>
>> LastVisible bar may be PAST (BarCount) because of blank space in the future.
>>
>> You should always iterate in the range 0... BarCount-1.
>>
>> Best regards,
>> Tomasz Janeczko
>> amibroker.com
>> ----- Original Message ----- 
>> From: "murthysuresh" <money@xxx>
>> To: <amibroker@xxxxxxxxxxxxxxx>
>> Sent: Sunday, March 08, 2009 7:44 PM
>> Subject: [amibroker] Error 10. Subscript out of range. You must not access array elements outside 0..
>>
>>
>> >i get the error when ther is white space on the right hand side as seen in this link.
>> > http://screencast.com/t/sxLi3oR8
>> >
>> > however my code seems to only loop between the fistvisible bar and lastvisiblebar. so i dont see why i should get a subscript 
>> > out
>> > of range error. when i scroll the chart to the right and if there is no white space, the error disapprears.
>> > appreciate any help
>> >
>> > StaticVarSetText( "TradeType" , "Stocks" );  //Stocks|Forex
>> > StaticVarSetText( "forexSymbol" , "PVTB" ); //"EUR.USD-IDEALPRO-CASH|
>> > StaticVarSetText( "StockSymbol", "PVTB" ); //  "YHOO"
>> > StaticVarSetText( "ShortOrLong" , "Short" );  //"Short|Long"
>> > StaticVarSetText( "EntryPrice" , "11.90000,11.90000" );
>> > StaticVarSetText( "ExitPrice" , "10.45000,10.45000" );
>> > StaticVarSetText( "EntryDate" , "1090303,1090303" );
>> > StaticVarSetText( "ExitDate" , "1090304,1090304" );
>> > StaticVarSetText( "EntryTime" , "95126,95126" );
>> > StaticVarSetText( "ExitTime" , "141019,141019" );
>> > StaticVarSet( "NoOfEntries" , 2 );
>> > StaticVarSet( "NoOfExits" , 2 );
>> > StaticVarSet( "Tradeid" , 1017 );
>> > StaticVarSetText( "TradeComments" , "" );
>> > StaticVarSetText( "TradeStrategy" , "" );
>> >
>> >
>> > dn = DateNum();
>> >
>> > tn = TimeNum();
>> >
>> >
>> > firstVisibleBar = Status( "firstvisiblebar" );
>> > lastVisibleBar = Status( "lastvisiblebar" );
>> >
>> > for ( b = firstVisibleBar;b < lastVisibleBar ;b++ )
>> >
>> > {
>> >    // START OF DAILY
>> >
>> >    for ( i = 0 ;i <2;i++ )
>> >    {
>> >        // _TRACE( "ABTest: test 182 " + "matchig dn " + NumToStr( dn[b] ) );
>> >        //  _TRACE( "ABTest: test 182 " + i );
>> >        EntryDatei = VarGet( "EntryDate"  + i ) ;
>> >
>> >        if ( ( EntryDatei  > dn[b] - 1 )  AND ( EntryDatei < dn[b] + 1 ) AND ( b < lastVisibleBar )  )
>> >        {
>> >
>> >            entryPrices[b] = VarGet( "EntryPrice" + i );
>> >            Buy[b] = Short[b] = True;
>> >            //_TRACE( "ABTest: test 182 matching price " + NumToStr( VarGet( "EntryPrice" + i ) ) ) ;
>> >            // _TRACE( "ABTest: test 182 matching price " + NumToStr( VarGet( "EntryPrice" + i ) ) ) ;
>> >
>> >
>> >
>> >            PlotText( ShortOrLong  +  " entry " + i + " " + ":" + entryPrices[b]   , b, ( yHigh + High[b] ) / 2, colorBlue );
>> >            PlotText( "entry" + entryPrices[b]  , b, EntryPrice0, colorBlue );
>> >
>> >            //  _TRACE( "ABTest: test 182 MATCHED " + NumToStr( VarGet( "EntryDate" + i ) ) + NumToStr( dn[b] ) );
>> >
>> >        }
>> >
>> >    }
>> > }
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > **** 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
>
>
>



------------------------------------

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