TC2000.com• Download software • Tutorial videos • Subscription & data-feed pricing • Class schedule
TC2000Brokerage.com• New account application • Trading resources • Margin rates • Stock & option commissions
Worden Discussion Forum
Stock and Market Talk
Help with conditions returning values of +1, 0 or -1
You were helping out Chris55 with some questions around having conditions return +1 and/or -1 values. My question is similar.
I understand that a Boolean condition will normally return +1 if true and 0 if not true. How do you write a formula that would return a -1 if true and a 0 if not true?
I have some bullish and bearish conditions that I want to combine in to an oscillator in histogram style so the +1 and -1 are necessary. Currently all the formulas return +1 or 0 and so the indicator never goes in to negative territory.
If conditions cannot return a -1 value, is it possible to have the boolean formula multiplied by -1?
If you put a Boolean formula inside parentheses as part of a formula designed to return a numeric value it returns -1 if true and 0 if false.
If you put a Boolean formula inside an ABS() function as part of a formula designed to return a numeric value it returns 1 if true and 0 if false.
You can use the IIF() function to get a Boolean formula to return any numeric value you want when true or false.