New version 18 available now


Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Help with conditions returning values of +1, 0 or -1 Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
jztrader
Posted : Friday, November 23, 2018 1:45:03 PM
Platinum Customer Platinum Customer

Joined: 12/4/2016
Posts: 4

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?

Thank you.

 
Bruce_L
Posted : Monday, November 26, 2018 10:00:17 AM


Worden Trainer

Joined: 10/7/2004
Posts: 64,322

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.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.