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


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

AND/OR operators Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
emthree
Posted : Monday, October 30, 2006 2:23:50 AM
Registered User
Joined: 10/7/2004
Posts: 30
I have written a PCF to locate stocks which meet the following conditions;

1) This week's high is a 4 week high.

2) This week's open and close must be in the bottom 25% of the week's range

OR

This week's open must gap to a new 4 week high and close below the
week's open on Friday.

---------------------------
(MAXH5 > MAXH15.5)

AND

(((C < (MINL5 + ((MAXH5 - MINL5) * 0.25))) AND (O4 < (MINL5 + ((MAXH5 - MINL5) * 0.25))))

OR

((O4 > MAXH15.5) AND (C < O4)))
------------------------------

Please let me know;

a) What happends if *both* conditions on either side of "OR" are true ?

b) Have I bracketed each condition correctly above ?

c) Do you have any suggestions on how I can avoid having to do so much
nesting within brackets ?

regards,
emthree.
bustermu
Posted : Monday, October 30, 2006 7:32:52 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
QUOTE (emthree)
a) What happends if *both* conditions on either side of "OR" are true?


The OR is a nonexclusive OR as usual so the OR statement is True.

QUOTE (emthree)
b) Have I bracketed each condition correctly above?


Yes.

QUOTE (emthree)
c) Do you have any suggestions on how I can avoid having to do so much nesting within brackets?


The TeleChart order of precedence is:
1) Arithmetic Operations.
2) Equalities and Inequalities.
3) OR.
4) AND.

The Conventional order of precedence is:
1) Arithmetic Operations.
2) Equalities and Inequalities.
3) AND.
4) OR.

For TeleChart, only the order of execution of AND and OR are reversed. You can use the order of precedence the eliminate parentheses.

Your PCF is:

(MAXH5>MAXH15.5)
AND
(((C<(MINL5+((MAXH5-MINL5)*0.25)))
AND
(O4<(MINL5+((MAXH5-MINL5)*0.25))))
OR
((O4>MAXH15.5)
AND
(C<O4)))

I have isolated the connectives AND and OR at the left margin for the visual effect only.

Using the TeleChart order of precedence, we can eliminate all but two sets of parentheses associated with the connectives. The resulting equivalent PCF is:

MAXH5>MAXH15.5
AND
(C<MINL5+(MAXH5-MINL5)*0.25
AND
O4<MINL5+(MAXH5-MINL5)*0.25)
OR
(O4>MAXH15.5
AND
C<O4)

Thanks,
Jim Murphy
emthree
Posted : Monday, October 30, 2006 10:46:07 AM
Registered User
Joined: 10/7/2004
Posts: 30
Jim,

Thanks for your suggestions.

On second thoughts, a novice like me is probably going to find it easier to the nesting within brackets than think abou the TC2007 order of precedence.

Going off topic; how do I keep written comments for my own reference within the PCFs ?
Bruce_L
Posted : Monday, October 30, 2006 10:52:43 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I do not know of a way to comment Personal Criteria Formulas in TeleChart.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bustermu
Posted : Monday, October 30, 2006 2:28:26 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
QUOTE (emthree)
On second thoughts, a novice like me is probably going to find it easier to the nesting within brackets than think abou the TC2007 order of precedence.


emthree,

If you knew how long it took me to read your PCF with all of those parentheses, you would likely modify your statement a little. Let's try to get you to modify it by using an example.

For backround, a WMA of Period 3 on the close is given by:

(3*C0+2*C1+1*C2)/6

Suppose we want a PCF for:

1) Todays close is greater than the WMA of Period 3 on the close, and, the close is greater than 10.

or,

2) Todays close is less than or equal to 10.

Suppose all operations are executed only as directed by parentheses. Then, a PCF satisfying the conditions is:

(((C0>((((3*C0)+(2*C1))+(1*C2))/6)) AND (C0>10)) OR (C0<=10))

Now, let's use the TeleChart Order of Precedence to remove those unnecessary parentheses:

(C0>(3*C0+2*C1+1*C2)/6 AND C0>10) OR C0<=10

My question is how long did it take you to read the first as opposed to the second? The first is what you are stuck with without an Order of Precedence. The first makes me dizzy.

We could resort to what is called "Polish Notation" and eliminate all parentheses. Many prefer that, but it also makes me dizzy.

Thanks,
Jim Murphy

PS: You seem to do quite well for one that calls himself a novice.
emthree
Posted : Monday, October 30, 2006 10:35:34 PM
Registered User
Joined: 10/7/2004
Posts: 30
Jim,

Thanks for the quick primer on order of precedence
I am going to get my teeth into this when I have some quiet time later.
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.