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 |

count up/down days Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
SpecuMan
Posted : Wednesday, April 15, 2009 11:29:41 AM
Registered User
Joined: 10/7/2004
Posts: 6
Hi, is there a way to count the up - or down days of e.g. the past 3 days? E.g. a stock had the past 3 days change; -1.3  +0.5   -0.1   --> result would be  -2  (2 down days). I tried something with the SGN function but couldn't get anything useful. So, the result would be a number, either  -3, -2, -1, 0 (in theory too), 1, 2, 3. 
Many thanks in advance for help.
Best regards.
Bruce_L
Posted : Wednesday, April 15, 2009 11:33:46 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The following would return a number between -3 and 3 depending on the number of up and down days, but it would not be a count of the number of up or down days (it is the number of up days minus the number of down days).

SGN(C - C1) + SGN(C1 - C2) + SGN(C2 - C3)

A count of the number of up days could be written as:

ABS(C > C1) + ABS(C1 > C2) + ABS(C2 > C3)

While a count of the number of down days could be written as:

ABS(C < C1) + ABS(C1 < C2) + ABS(C2 < C3)

You may wish to review the following:

PCF Formula Descriptions
How to create a Personal Criteria Forumula (PCF)
Handy PCF example formulas to help you learn the syntax of PCFs!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
SpecuMan
Posted : Wednesday, April 15, 2009 11:50:45 AM
Registered User
Joined: 10/7/2004
Posts: 6

OK. A bit different than what I wanted but still useful, I keep using my SGN pcf also. Are there new operators or functions for use in PCFs which haven't been documented? There is no way to program IF statements, in the future either? 
OK, many thanks, regards.

Bruce_L
Posted : Wednesday, April 15, 2009 11:59:43 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The first topic referenced in my reply includes undocumented functions. The ABS() technique used in the second two formulas can be used as a conditional since it returns 1 if True and 0 if False. This means you can multiply it by something else and only get a result when it is True.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
gsn
Posted : Friday, November 18, 2011 2:37:41 PM
Registered User
Joined: 11/13/2004
Posts: 121
How would ABS be used in the following formula, which is basically trying to count how many days traded either PUVU or PDVD?

(C > C1 AND V > V1) OR (C < C1 AND V < V1) +
(C1 > C2 AND V1 > V2) OR (C1 < C2 AND V1 < V2) +
(C2 > C3 AND V2 > V3) OR (C2 < C3 AND V2 < V3) +
(C3 > C4 AND V3 > V4) OR (C3 < C4 AND V3 < V4) +
(C4 > C5 AND V4 > V5) OR (C4 < C5 AND V4 < V5) +
(C5 > C6 AND V5 > V6) OR (C5 < C6 AND V5 < V6) +
(C6 > C7 AND V6 > V7) OR (C6 < C7 AND V6 < V7) +
(C7 > C8 AND V7 > V8) OR (C7 < C8 AND V7 < V8) +
(C8 > C9 AND V8 > V9) OR (C8 < C9 AND V8 < V9) +
(C9 > C10 AND V9 > V10) OR (C9 < C10 AND V9 < V10) +
(C10 > C11 AND V10 > V11) OR (C10 < C11 AND V10 < V11) +
(C11 > C12 AND V11 > V12) OR (C11 < C12 AND V11 < V12) +
(C12 > C13 AND V12 > V13) OR (C12 < C13 AND V12 < V13) +
(C13 > C14 AND V13 > V14) OR (C13 < C14 AND V13 < V14) +
(C14 > C15 AND V14 > V15) OR (C14 < C15 AND V14 < V15) +
(C15 > C16 AND V15 > V16) OR (C15 < C16 AND V15 < V16) +
(C16 > C17 AND V16 > V17) OR (C16 < C17 AND V16 < V17) +
(C17 > C18 AND V17 > V18) OR (C17 < C18 AND V17 < V18) +
(C18 > C19 AND V18 > V19) OR (C18 < C19 AND V18 < V19) +
(C19 > C20 AND V19 > V20) OR (C19 < C20 AND V19 < V20) +
(C20 > C21 AND V20 > V21) OR (C20 < C21 AND V20 < V21) +
(C21 > C22 AND V21 > V22) OR (C21 < C22 AND V21 < V22) +
(C22 > C23 AND V22 > V23) OR (C22 < C23 AND V22 < V23) +
(C23 > C24 AND V23 > V24) OR (C23 < C24 AND V23 < V24) +
(C24 > C25 AND V24 > V25) OR (C24 < C25 AND V24 < V25) +
(C25 > C6 AND V25 > V26) OR (C25 < C26 AND V25 < V26)
Bruce_L
Posted : Friday, November 18, 2011 2:44:30 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
In general, you would put it around each boolean exression you wish to count if true. So I'm guessing:

ABS((C > C1 AND V > V1) OR (C < C1 AND V < V1)) +
ABS((C1 > C2 AND V1 > V2) OR (C1 < C2 AND V1 < V2)) +
ABS((C2 > C3 AND V2 > V3) OR (C2 < C3 AND V2 < V3)) +
ABS((C3 > C4 AND V3 > V4) OR (C3 < C4 AND V3 < V4)) +
ABS((C4 > C5 AND V4 > V5) OR (C4 < C5 AND V4 < V5)) +
ABS((C5 > C6 AND V5 > V6) OR (C5 < C6 AND V5 < V6)) +
ABS((C6 > C7 AND V6 > V7) OR (C6 < C7 AND V6 < V7)) +
ABS((C7 > C8 AND V7 > V8) OR (C7 < C8 AND V7 < V8)) +
ABS((C8 > C9 AND V8 > V9) OR (C8 < C9 AND V8 < V9)) +
ABS((C9 > C10 AND V9 > V10) OR (C9 < C10 AND V9 < V10)) +
ABS((C10 > C11 AND V10 > V11) OR (C10 < C11 AND V10 < V11)) +
ABS((C11 > C12 AND V11 > V12) OR (C11 < C12 AND V11 < V12)) +
ABS((C12 > C13 AND V12 > V13) OR (C12 < C13 AND V12 < V13)) +
ABS((C13 > C14 AND V13 > V14) OR (C13 < C14 AND V13 < V14)) +
ABS((C14 > C15 AND V14 > V15) OR (C14 < C15 AND V14 < V15)) +
ABS((C15 > C16 AND V15 > V16) OR (C15 < C16 AND V15 < V16)) +
ABS((C16 > C17 AND V16 > V17) OR (C16 < C17 AND V16 < V17)) +
ABS((C17 > C18 AND V17 > V18) OR (C17 < C18 AND V17 < V18)) +
ABS((C18 > C19 AND V18 > V19) OR (C18 < C19 AND V18 < V19)) +
ABS((C19 > C20 AND V19 > V20) OR (C19 < C20 AND V19 < V20)) +
ABS((C20 > C21 AND V20 > V21) OR (C20 < C21 AND V20 < V21)) +
ABS((C21 > C22 AND V21 > V22) OR (C21 < C22 AND V21 < V22)) +
ABS((C22 > C23 AND V22 > V23) OR (C22 < C23 AND V22 < V23)) +
ABS((C23 > C24 AND V23 > V24) OR (C23 < C24 AND V23 < V24)) +
ABS((C24 > C25 AND V24 > V25) OR (C24 < C25 AND V24 < V25)) +
ABS((C25 > C26 AND V25 > V26) OR (C25 < C26 AND V25 < V26))

PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!

-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.