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

Re: [amibroker] I guess I don’t get Boolean, maybe someone can help



PureBytes Links

Trading Reference Links

Hi Best --

There are two AFL operators that look alike but are very different -- IF and  IIF.

//---------------------------------

IIF is a function.  Its syntax is IIF(boolean, TruePart, FalsePart); and it returns an array as a result; Typical use is as part of a regular AFL program.  For example

UpDay = IIF(C>Ref(C,-1),C-Ref(C-1),0);

Test to see if today's close is greater than yesterday's close.  If it is, return the change, if it is not, return 0.

//----------------------------------

IF is a flow control statement, part of IF ... ELSE.  The operand of IF must be a scalar, not an array.  IF is most often used within looping code, where you are stepping through all of the data bars yourself. For example
for (i=1; i<BarCount; i++)
{

// some other code

IF(C[i] > C[i-1])
{
UpDay[i] = C[i]-C[i-1];
}
ELSE
{
UpDay[i] = 0;
}

//------------------------------------

Thanks,
Howard




On Sun, Sep 14, 2008 at 6:06 PM, bestleonard <bestleonard@xxxxxxxxx> wrote:

Hi,

I keep getting error 6 with 'IF' statement.
I have a long conditional like:

Omc = (C0 > eh13) AND (Op0 < wbx150) AND (C0 < the75pzone) AND
myind1 AND sup5up AND n17up ;

(Then:)

Fcase = "a";

if ( omc) Fcase = "b";

I keep getting error 6.

I've changed the 'Boolean' _expression_ to Ref(omc, 0) and
If (omc > 0) and a few other variations.

My filter is a bunch of `OR' statements and I want to, with an
addtextcolum statement display which `OR' statement got through the
filter statement.

And I've searched the maual. The words 'and' and 'or' are not
in the reserved word list, and I don't think boolean is defined,
but I could be wrong.

Thanks In advance for showing me the error of my ways. An example
of how to do this would be great. Want I want is the iif with no
action when the statement is false.


__._,_.___

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




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

__,_._,___