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 |

SECOND HIGHEST HIGH Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Quiktdr
Posted : Saturday, January 21, 2006 8:38:02 PM
Registered User
Joined: 10/7/2004
Posts: 794
How would one write a PCF for the second highest high or second lowest low over the last 20 days?


Thank you in advance!
Bruce_L
Posted : Monday, January 23, 2006 6:23:51 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
A technique is described here, but the formulas will be rather long if written for 20-Periods:

PCF for Order Statistics

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bustermu
Posted : Tuesday, January 24, 2006 7:19:42 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Quiktdr,

As seen in the link given by Bruce, in general, a PCF for the second higest of 20 quantities is not practical because of its length. Fortunately, there is sometimes a way around this problem.

Since the MAX function is available on H, there is a PCF for the second highest high whose length only grows linearly with the period.

A PCF for the second highest high for the last 5 days is:

(-1)
*((H0=MAXH5)*MAXH4.1-(H0<MAXH5)
*((H1=MAXH5)*(MAXH1+MAXH3.2+ABS(MAXH1-MAXH3.2))/2-(H1<MAXH5)
*((H2=MAXH5)*(MAXH2+MAXH2.3+ABS(MAXH2-MAXH2.3))/2-(H2<MAXH5)
*((H3=MAXH5)*(MAXH3+MAXH1.4+ABS(MAXH3-MAXH1.4))/2-(H3<MAXH5)
*((H4=MAXH5)*MAXH4
)))))

The form of a PCF for the second higest high for the last 20 days is:

(-1)
*((H0=MAXH20)*MAXH19.1-(H0<MAXH20)
*((H1=MAXH20)*(MAXH1+MAXH18.2+ABS(MAXH1-MAXH18.2))/2-(H1<MAXH20)
*((H2=MAXH20)*(MAXH2+MAXH17.3+ABS(MAXH2-MAXH17.3))/2-(H2<MAXH20)
*...
*((H18=MAXH20)*(MAXH18+MAXH1.19+ABS(MAXH18-MAXH1.19))/2-(H18<MAXH20)
*((H19=MAXH20)*MAXH19
)))...))

One need only supply the 15 missing lines and )'s.

The PCFs for the second lowest low are obtained from the above by replacing:

MAX by MIN
+ABS by -ABS
H by L
< by >

Thanks,
Jim Murphy
Bruce_L
Posted : Tuesday, January 24, 2006 9:06:47 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Quiktdr,
Here they are just in case you didn't want to go through the process of filling in the blanks of bustermu's excellent post:

Second highest high for the last 20 days:

( - 1) * ((H = MAXH20) * MAXH19.1 - (H < MAXH20) * ((H1 = MAXH20) * (MAXH1 + MAXH18.2 + ABS(MAXH1 - MAXH18.2)) / 2 - (H1 < MAXH20) * ((H2 = MAXH20) * (MAXH2 + MAXH17.3 + ABS(MAXH2 - MAXH17.3)) / 2 - (H2 < MAXH20) * ((H3 = MAXH20) * (MAXH3 + MAXH16.4 + ABS(MAXH3 - MAXH16.4)) / 2 - (H3 < MAXH20) * ((H4 = MAXH20) * (MAXH4 + MAXH15.5 + ABS(MAXH4 - MAXH15.5)) / 2 - (H4 < MAXH20) * ((H5 = MAXH20) * (MAXH5 + MAXH14.6 + ABS(MAXH5 - MAXH14.6)) / 2 - (H5 < MAXH20) * ((H6 = MAXH20) * (MAXH6 + MAXH13.7 + ABS(MAXH6 - MAXH13.7)) / 2 - (H6 < MAXH20) * ((H7 = MAXH20) * (MAXH7 + MAXH12.8 + ABS(MAXH7 - MAXH12.8)) / 2 - (H7 < MAXH20) * ((H8 = MAXH20) * (MAXH8 + MAXH11.9 + ABS(MAXH8 - MAXH11.9)) / 2 - (H8 < MAXH20) * ((H9 = MAXH20) * (MAXH9 + MAXH10.10 + ABS(MAXH9 - MAXH10.10)) / 2 - (H9 < MAXH20) * ((H10 = MAXH20) * (MAXH10 + MAXH9.11 + ABS(MAXH10 - MAXH9.11)) / 2 - (H10 < MAXH20) * ((H11 = MAXH20) * (MAXH11 + MAXH8.12 + ABS(MAXH11 - MAXH8.12)) / 2 - (H11 < MAXH20) * ((H12 = MAXH20) * (MAXH12 + MAXH7.13 + ABS(MAXH12 - MAXH7.13)) / 2 - (H12 < MAXH20) * ((H13 = MAXH20) * (MAXH13 + MAXH6.14 + ABS(MAXH13 - MAXH6.14)) / 2 - (H13 < MAXH20) * ((H14 = MAXH20) * (MAXH14 + MAXH5.15 + ABS(MAXH14 - MAXH5.15)) / 2 - (H14 < MAXH20) * ((H15 = MAXH20) * (MAXH15 + MAXH4.16 + ABS(MAXH15 - MAXH4.16)) / 2 - (H15 < MAXH20) * ((H16 = MAXH20) * (MAXH16 + MAXH3.17 + ABS(MAXH16 - MAXH3.17)) / 2 - (H16 < MAXH20) * ((H17 = MAXH20) * (MAXH17 + MAXH2.18 + ABS(MAXH17 - MAXH2.18)) / 2 - (H17 < MAXH20) * ((H18 = MAXH20) * (MAXH18 + MAXH1.19 + ABS(MAXH18 - MAXH1.19)) / 2 - (H18 < MAXH20) * ((H19 = MAXH20) * MAXH19))))))))))))))))))))

Second lowest low for the last 20 days:

( - 1) * ((L = MINL20) * MINL19.1 - (L > MINL20) * ((L1 = MINL20) * (MINL1 + MINL18.2 - ABS(MINL1 - MINL18.2)) / 2 - (L1 > MINL20) * ((L2 = MINL20) * (MINL2 + MINL17.3 - ABS(MINL2 - MINL17.3)) / 2 - (L2 > MINL20) * ((L3 = MINL20) * (MINL3 + MINL16.4 - ABS(MINL3 - MINL16.4)) / 2 - (L3 > MINL20) * ((L4 = MINL20) * (MINL4 + MINL15.5 - ABS(MINL4 - MINL15.5)) / 2 - (L4 > MINL20) * ((L5 = MINL20) * (MINL5 + MINL14.6 - ABS(MINL5 - MINL14.6)) / 2 - (L5 > MINL20) * ((L6 = MINL20) * (MINL6 + MINL13.7 - ABS(MINL6 - MINL13.7)) / 2 - (L6 > MINL20) * ((L7 = MINL20) * (MINL7 + MINL12.8 - ABS(MINL7 - MINL12.8)) / 2 - (L7 > MINL20) * ((L8 = MINL20) * (MINL8 + MINL11.9 - ABS(MINL8 - MINL11.9)) / 2 - (L8 > MINL20) * ((L9 = MINL20) * (MINL9 + MINL10.10 - ABS(MINL9 - MINL10.10)) / 2 - (L9 > MINL20) * ((L10 = MINL20) * (MINL10 + MINL9.11 - ABS(MINL10 - MINL9.11)) / 2 - (L10 > MINL20) * ((L11 = MINL20) * (MINL11 + MINL8.12 - ABS(MINL11 - MINL8.12)) / 2 - (L11 > MINL20) * ((L12 = MINL20) * (MINL12 + MINL7.13 - ABS(MINL12 - MINL7.13)) / 2 - (L12 > MINL20) * ((L13 = MINL20) * (MINL13 + MINL6.14 - ABS(MINL13 - MINL6.14)) / 2 - (L13 > MINL20) * ((L14 = MINL20) * (MINL14 + MINL5.15 - ABS(MINL14 - MINL5.15)) / 2 - (L14 > MINL20) * ((L15 = MINL20) * (MINL15 + MINL4.16 - ABS(MINL15 - MINL4.16)) / 2 - (L15 > MINL20) * ((L16 = MINL20) * (MINL16 + MINL3.17 - ABS(MINL16 - MINL3.17)) / 2 - (L16 > MINL20) * ((L17 = MINL20) * (MINL17 + MINL2.18 - ABS(MINL17 - MINL2.18)) / 2 - (L17 > MINL20) * ((L18 = MINL20) * (MINL18 + MINL1.19 - ABS(MINL18 - MINL1.19)) / 2 - (L18 > MINL20) * ((L19 = MINL20) * MINL19))))))))))))))))))))

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Quiktdr
Posted : Tuesday, January 24, 2006 12:04:14 PM
Registered User
Joined: 10/7/2004
Posts: 794
Kudos to Bustermu!

Thank you Bruce!
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.