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

Re: [amibroker] Conditional include



PureBytes Links

Trading Reference Links

Hello,
 
First, you have to use BRACES, since #include simply "pastes" code from external file in the place when
it is used, so you end up with MULTIPLE lines (so they have to be enclosed in braces.
 
Second thing is that your newBuy and newSell are ARRAYS and can not be used in "if" condition
 
 
So corrected code would look as follows:
 
 if ( LastValue( newBuy OR newSell ) )
 {

        #include <W_Xfactor.afl>

 }

 else

        tradeLevel = trange = 1;

 
 
However please note that this operates on lastvalue only, not on bar-by-bar basis.
 
Please read Understanding AFL
 
to learn how AmiBroker processes array statements.
 
If you need bar-by-bar execution you need to write a LOOP.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Terry
Sent: Tuesday, September 06, 2005 4:47 PM
Subject: [amibroker] Conditional include

I would like to conditionally load and execute an Include file only on days when certain conditions are True. I do this with ParamToggle all the time since ParamToggle creates a numeric or Boolean condition. Now I want to do it only on days when I have a Buy or Sell condition which is in an array and Amibroker complains that array is not allowed in an if() statement. IIf is not acceptable since it is just an assignment statement. I don’t want to build a loop since the include file uses arrays.

 

Here’s the code. Any ideas?

 

 

    if (newBuy OR newSell)

        #include <W_Xfactor.afl>

    else

        tradeLevel = trange = 1;

 

Error 6. Condition in IF, WHITEL, FOR statements ahs to be Numeric or Boolean type. You can not use array here, please use [] (array subscript operator) to access array elements.

--

Terry

 



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 other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS