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

[amibroker] Re: Access Error when trying to VarGet from within a VarSet loop



PureBytes Links

Trading Reference Links



Your code seems to work fine for me, using arbitrary values for Counter and TestLevel.

Add a _TRACE statement to validate your HiLoCond values.

I seem to recall getting access violations when using invalid index values (e.g. referencing beyond the data). You might want to look there.

Also, you can avoid the redundant VarGet calls by storing your earlier results in local variables and reusing them, rather than doing a dynamic lookup for something that you just calculated.

Mike

for ( R = 0; R <= Counter; R++ )
{
    MyHigh =
Ref( High
, -R );
    MyLow =
Ref( Low
, -R );

    
VarSet( "High"
     + R, MyHigh );
    
VarSet( "Low"
      + R, MyLow );

    
VarSet( "HiLoCond"
+ R, MyHigh - MyLow >= TestLevel ) ;
}


--- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> wrote:
>
> Hoping someone can help with this. I am getting an Access Violation
> AmiBroker crash, and it seems to be due to using VarGet from within a
> VarSet loop, or at least I think that is where the problem lies.
>
> For example, I have several loops of this type:
>
>
> for ( R = 0; R <= Counter; R++ )
> {
> VarSet( "High" + R, Ref( High, -R ) );
> VarSet( "Low" + R, Ref( Low, -R ) );
>
> VarSet( "HiLoCond" + R, VarGet( "High" + R ) - VarGet("Low" + R) >=
> TestLevel ) ;
> }
>
>
>
> You will notice I am setting some dynamic vars, and within the same loop
> I am getting vars which have been set earlier in the loop. Is this
> allowed? Or can I only do a VarGet from inside a completely separate
> loop? I would think that in the order of execution, I can do what I am
> doing, since the vars are set a couple of lines above, but maybe not?
>



__._,_.___


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





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

__,_._,___