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

Re: Booleans



PureBytes Links

Trading Reference Links

> Q1.  This doesn't work:
> upclose = iff(close>open, TRUE, FALSE);
> The debugger says I need numeric expressions instead of TRUE and
> FALSE.  Is there any solution other than making my upclose Boolean
> variable numeric? 

iff() can return only numeric values, so you can't use it as you show 
above.  However you don't need it here.  

> Q2.  Could I abbreviate the upclose statement as
> upclose = close>open;
> like I could in C?

Yes.  That's how I'd do it.

> Q3.  When checking upclose can I say
> if upclose then ...
> or do I need to go
> if upclose = TRUE then ...?

"if upclose then" works fine.

> Q4.  How about for false?  Can I say
> if !upclose then ... ?

Nope.  There's no negation operator in EL.  Use "if upclose = False".

> Q5.  Should I skip Booleans altogether and just use 1 or 0 in a
> numeric variable? 

Your choice.  I prefer booleans, unless it's an input -- then I often 
use numeric 1/0 values so I can change the value in an optimization.  
(Optimized inputs can only take on numeric values.)

Gary





  • References: