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 |

Days Since Last Peak (or other day-counting needs) Topic Rating:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Tanstaafl
Posted : Thursday, December 9, 2004 7:18:28 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
I originally posted this in response to a request for a new PCF function to identify how to write a PCF to tell WHAT day was THE day that set the High of the last five days. But since it's a viable technique, I've moved the post here. I hope y'all find it to be helpful ....

You can do this, albeit awkwardly, using the current PCF language. If your search window is fairly short, and the function or price is a simple one, this solution works fine. Here goes:

Solution:
To find how many days ago the MaxH5 value actually occured, you need to check each of the past five days to see if it equals that value, and output the daysago number for that day.

Important trick:
Any boolean (True/false) expression in PCF-eze can be enclosed in parentheses and used as a numeric value in a formula. "True" changes into a minus one, and "false" changes into a zero. This is a very, very useful technique.

For each day in our search, we check if the high for that day is equal to the MaxH5, and if so, we output the day number (we will call today day #1, yesterday day #2 and so on. For the current day, with High value "H0":
(H0=MaxH5)*(-1)
will output +1 if today's high hit the max, or 0 if not

Expand this to five days:
(H0=MaxH5)*(-1)
- (H1=MaxH5)*2
- (H2=MaxH5)*3
- (H3=MaxH5)*4
- (H4=MaxH5)*5


The minus signs are used to convert the -1 "True" multiplier to a +1 multiplier.

At first glance (once you digest this info), you might presume that the possible answers are 1,2,3,4,5. Not quite.

What happens if you hit the same MaxH more than once? For example, if H2=MaxH5 and H3=MaxH5, but the others don't, the answer will be 3+4 = 7. Not very useful ... particularly since you can get a result of 5 in three different ways (figger it out!)

So, here's another method ... reserve one power-of-ten for each of the five days. Check this out:

(H0=MaxH5)*(-1)
- (H1=MaxH5)*20
- (H2=MaxH5)*300
- (H3=MaxH5)*4000
- (H4=MaxH5)*50000

Our prior example, with hits on H2 and H3, will yield an answer of 4300.

OK ... that's pretty clear ... but what if you have to check 20 days? There aren't enough digits available in the pcf display (or internal calc variable) to hold them?

In that case, you need to decide ahead of time, in the case that you have multiple hits, whether the most recent one should be reported, or the oldest one.

If you want to know the most recent of five hits (I'm sticking with five to keep the example short, but you can expanding this out till your fingers get tired if you want):

(H0=MaxH5)*(-1) + (H0<>MaxH5)* (
(H1=MaxH5)*(-2) + (H1<>MaxH5)* (
(H2=MaxH5)*(-3) + (H2<>MaxH5)* (
(H3=MaxH5)*(-4) + (H3<>MaxH5)* (
(H4=MaxH5)*(-5) ))))

This will print out a 2 if the most recent hit was on the H1 day, even if all three prior days were pinned at the MaxH5.

The tricks are:
1) the "Hn<>MaxH5" terms evaluate to the OPPOSITE of the "Hn=MaxH5" terms, and
2) the progressive days are "nested" in parens, so the more recent days override any earlier ones

Just remember: boolean True becomes -1, and boolean False becomes 0, as long as you wrap the entire boolean expression in paren's.

For those of you who care ... this *IS* an "If-Then-Else" clause for TC.

Too bad their is no shortcut to looping! :~)



alatar
Posted : Thursday, December 9, 2004 10:30:14 PM
Registered User
Joined: 10/7/2004
Posts: 4
Location: Suwanee, GA
As I noted in the original thread:

Jim Dean's logic is, as always, beautiful and irrefutable. But you can improve processing speed by reducing the number of nested parentheses with the following formula to determine the number of days since the high was observed.

5
+ 5*(H0=maxH5)
- 4*(H1=maxH5)*(H1>H0)
- 3*(H2=maxH5)*(H2>maxH2)
- 2*(H3=maxH5)*(H3>maxH3)
- 1*(H4=maxH5)*(H4>maxH4)

In addition to my original post, I would offer the following as the general formula for counting the number of bars since the highest value was observed over the last [n] bars:

[n]
+ [n]*(H0=maxH[n])
- [n-1]*(H1=maxH[n])*(H1>H0)
- [n-2]*(H2=maxH[n])*(H2>maxH2)
- ...
- 1*(H[n-1]=maxH[n])*(H[n-1]>maxH[n-1])

Likewise, following is the general formula for counting the number of bars since the lowest value was observed over the last [n] bars:

[n]
+ [n]*(L0=maxL[n])
- [n-1]*(L1=minL[n])*(L1<L0)
- [n-2]*(L2=minL[n])*(L2<minL2)
- ...
- 1*(L[n-1]=minL[n])*(L[n-1]<minL[n-1])

Ken Powers
aka "alatar"

Tanstaafl
Posted : Thursday, December 9, 2004 10:43:59 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Ken's solution is much more elegant than mine. As he says, the absence of nested paren's will significantly improve recalc speed. Another major speed improvement with his approach, which will show up particularly well in longer windows, is that the MaxH function is shorter in the second part of each day's row than the full span. Max and Min functions, when repeated in a formula, can eat a lot of time.

It's probably a bit harder for people to understand at first glance, but it is definitely a better solution.

Thanks for providing the generalized terms, Ken.
Really nice job!


brianj2
Posted : Monday, March 20, 2006 9:46:54 PM
Registered User
Joined: 3/14/2006
Posts: 23
I know it has been a long time since these were posted, but it gives me an idea for building multi-value sort keys... unless someone already has an idea for that one.
MarcM
Posted : Saturday, September 2, 2006 2:51:19 AM
Registered User
Joined: 2/27/2005
Posts: 59
I wrote a program to expand the formula out to 150 days. Please find it below. I don't understand why it generates both positive and negative values. I use it in a function to sort stocks by 'days since their low' and I get values ranging from 150 to -150. Any ideas what happening? Thanks.


(L0 = MINC150) * ( - 1) + (L0 <> MINC150) * ( (L1 = MINC150) * ( - 2) + (L1 <> MINC150) * ( (L2 = MINC150) * ( - 3) + (L2 <> MINC150) * ( (L3 = MINC150) * ( - 4) + (L3 <> MINC150) * ( (L4 = MINC150) * ( - 5) + (L4 <> MINC150) * ( (L5 = MINC150) * ( - 6) + (L5 <> MINC150) * ( (L6 = MINC150) * ( - 7) + (L6 <> MINC150) * ( (L7 = MINC150) * ( - 8) + (L7 <> MINC150) * ( (L8 = MINC150) * ( - 9) + (L8 <> MINC150) * ( (L9 = MINC150) * ( - 10) + (L9 <> MINC150) * ( (L10 = MINC150) * ( - 11) + (L10 <> MINC150) * ( (L11 = MINC150) * ( - 12) + (L11 <> MINC150) * ( (L12 = MINC150) * ( - 13) + (L12 <> MINC150) * ( (L13 = MINC150) * ( - 14) + (L13 <> MINC150) * ( (L14 = MINC150) * ( - 15) + (L14 <> MINC150) * ( (L15 = MINC150) * ( - 16) + (L15 <> MINC150) * ( (L16 = MINC150) * ( - 17) + (L16 <> MINC150) * ( (L17 = MINC150) * ( - 18) + (L17 <> MINC150) * ( (L18 = MINC150) * ( - 19) + (L18 <> MINC150) * ( (L19 = MINC150) * ( - 20) + (L19 <> MINC150) * ( (L20 = MINC150) * ( - 21) + (L20 <> MINC150) * ( (L21 = MINC150) * ( - 22) + (L21 <> MINC150) * ( (L22 = MINC150) * ( - 23) + (L22 <> MINC150) * ( (L23 = MINC150) * ( - 24) + (L23 <> MINC150) * ( (L24 = MINC150) * ( - 25) + (L24 <> MINC150) * ( (L25 = MINC150) * ( - 26) + (L25 <> MINC150) * ( (L26 = MINC150) * ( - 27) + (L26 <> MINC150) * ( (L27 = MINC150) * ( - 28) + (L27 <> MINC150) * ( (L28 = MINC150) * ( - 29) + (L28 <> MINC150) * ( (L29 = MINC150) * ( - 30) + (L29 <> MINC150) * ( (L30 = MINC150) * ( - 31) + (L30 <> MINC150) * ( (L31 = MINC150) * ( - 32) + (L31 <> MINC150) * ( (L32 = MINC150) * ( - 33) + (L32 <> MINC150) * ( (L33 = MINC150) * ( - 34) + (L33 <> MINC150) * ( (L34 = MINC150) * ( - 35) + (L34 <> MINC150) * ( (L35 = MINC150) * ( - 36) + (L35 <> MINC150) * ( (L36 = MINC150) * ( - 37) + (L36 <> MINC150) * ( (L37 = MINC150) * ( - 38) + (L37 <> MINC150) * ( (L38 = MINC150) * ( - 39) + (L38 <> MINC150) * ( (L39 = MINC150) * ( - 40) + (L39 <> MINC150) * ( (L40 = MINC150) * ( - 41) + (L40 <> MINC150) * ( (L41 = MINC150) * ( - 42) + (L41 <> MINC150) * ( (L42 = MINC150) * ( - 43) + (L42 <> MINC150) * ( (L43 = MINC150) * ( - 44) + (L43 <> MINC150) * ( (L44 = MINC150) * ( - 45) + (L44 <> MINC150) * ( (L45 = MINC150) * ( - 46) + (L45 <> MINC150) * ( (L46 = MINC150) * ( - 47) + (L46 <> MINC150) * ( (L47 = MINC150) * ( - 48) + (L47 <> MINC150) * ( (L48 = MINC150) * ( - 49) + (L48 <> MINC150) * ( (L49 = MINC150) * ( - 50) + (L49 <> MINC150) * ( (L50 = MINC150) * ( - 51) + (L50 <> MINC150) * ( (L51 = MINC150) * ( - 52) + (L51 <> MINC150) * ( (L52 = MINC150) * ( - 53) + (L52 <> MINC150) * ( (L53 = MINC150) * ( - 54) + (L53 <> MINC150) * ( (L54 = MINC150) * ( - 55) + (L54 <> MINC150) * ( (L55 = MINC150) * ( - 56) + (L55 <> MINC150) * ( (L56 = MINC150) * ( - 57) + (L56 <> MINC150) * ( (L57 = MINC150) * ( - 58) + (L57 <> MINC150) * ( (L58 = MINC150) * ( - 59) + (L58 <> MINC150) * ( (L59 = MINC150) * ( - 60) + (L59 <> MINC150) * ( (L60 = MINC150) * ( - 61) + (L60 <> MINC150) * ( (L61 = MINC150) * ( - 62) + (L61 <> MINC150) * ( (L62 = MINC150) * ( - 63) + (L62 <> MINC150) * ( (L63 = MINC150) * ( - 64) + (L63 <> MINC150) * ( (L64 = MINC150) * ( - 65) + (L64 <> MINC150) * ( (L65 = MINC150) * ( - 66) + (L65 <> MINC150) * ( (L66 = MINC150) * ( - 67) + (L66 <> MINC150) * ( (L67 = MINC150) * ( - 68) + (L67 <> MINC150) * ( (L68 = MINC150) * ( - 69) + (L68 <> MINC150) * ( (L69 = MINC150) * ( - 70) + (L69 <> MINC150) * ( (L70 = MINC150) * ( - 71) + (L70 <> MINC150) * ( (L71 = MINC150) * ( - 72) + (L71 <> MINC150) * ( (L72 = MINC150) * ( - 73) + (L72 <> MINC150) * ( (L73 = MINC150) * ( - 74) + (L73 <> MINC150) * ( (L74 = MINC150) * ( - 75) + (L74 <> MINC150) * ( (L75 = MINC150) * ( - 76) + (L75 <> MINC150) * ( (L76 = MINC150) * ( - 77) + (L76 <> MINC150) * ( (L77 = MINC150) * ( - 78) + (L77 <> MINC150) * ( (L78 = MINC150) * ( - 79) + (L78 <> MINC150) * ( (L79 = MINC150) * ( - 80) + (L79 <> MINC150) * ( (L80 = MINC150) * ( - 81) + (L80 <> MINC150) * ( (L81 = MINC150) * ( - 82) + (L81 <> MINC150) * ( (L82 = MINC150) * ( - 83) + (L82 <> MINC150) * ( (L83 = MINC150) * ( - 84) + (L83 <> MINC150) * ( (L84 = MINC150) * ( - 85) + (L84 <> MINC150) * ( (L85 = MINC150) * ( - 86) + (L85 <> MINC150) * ( (L86 = MINC150) * ( - 87) + (L86 <> MINC150) * ( (L87 = MINC150) * ( - 88) + (L87 <> MINC150) * ( (L88 = MINC150) * ( - 89) + (L88 <> MINC150) * ( (L89 = MINC150) * ( - 90) + (L89 <> MINC150) * ( (L90 = MINC150) * ( - 91) + (L90 <> MINC150) * ( (L91 = MINC150) * ( - 92) + (L91 <> MINC150) * ( (L92 = MINC150) * ( - 93) + (L92 <> MINC150) * ( (L93 = MINC150) * ( - 94) + (L93 <> MINC150) * ( (L94 = MINC150) * ( - 95) + (L94 <> MINC150) * ( (L95 = MINC150) * ( - 96) + (L95 <> MINC150) * ( (L96 = MINC150) * ( - 97) + (L96 <> MINC150) * ( (L97 = MINC150) * ( - 98) + (L97 <> MINC150) * ( (L98 = MINC150) * ( - 99) + (L98 <> MINC150) * ( (L99 = MINC150) * ( - 100) + (L99 <> MINC150) * ( (L100 = MINC150) * ( - 101) + (L100 <> MINC150) * ( (L101 = MINC150) * ( - 102) + (L101 <> MINC150) * ( (L102 = MINC150) * ( - 103) + (L102 <> MINC150) * ( (L103 = MINC150) * ( - 104) + (L103 <> MINC150) * ( (L104 = MINC150) * ( - 105) + (L104 <> MINC150) * ( (L105 = MINC150) * ( - 106) + (L105 <> MINC150) * ( (L106 = MINC150) * ( - 107) + (L106 <> MINC150) * ( (L107 = MINC150) * ( - 108) + (L107 <> MINC150) * ( (L108 = MINC150) * ( - 109) + (L108 <> MINC150) * ( (L109 = MINC150) * ( - 110) + (L109 <> MINC150) * ( (L110 = MINC150) * ( - 111) + (L110 <> MINC150) * ( (L111 = MINC150) * ( - 112) + (L111 <> MINC150) * ( (L112 = MINC150) * ( - 113) + (L112 <> MINC150) * ( (L113 = MINC150) * ( - 114) + (L113 <> MINC150) * ( (L114 = MINC150) * ( - 115) + (L114 <> MINC150) * ( (L115 = MINC150) * ( - 116) + (L115 <> MINC150) * ( (L116 = MINC150) * ( - 117) + (L116 <> MINC150) * ( (L117 = MINC150) * ( - 118) + (L117 <> MINC150) * ( (L118 = MINC150) * ( - 119) + (L118 <> MINC150) * ( (L119 = MINC150) * ( - 120) + (L119 <> MINC150) * ( (L120 = MINC150) * ( - 121) + (L120 <> MINC150) * ( (L121 = MINC150) * ( - 122) + (L121 <> MINC150) * ( (L122 = MINC150) * ( - 123) + (L122 <> MINC150) * ( (L123 = MINC150) * ( - 124) + (L123 <> MINC150) * ( (L124 = MINC150) * ( - 125) + (L124 <> MINC150) * ( (L125 = MINC150) * ( - 126) + (L125 <> MINC150) * ( (L126 = MINC150) * ( - 127) + (L126 <> MINC150) * ( (L127 = MINC150) * ( - 128) + (L127 <> MINC150) * ( (L128 = MINC150) * ( - 129) + (L128 <> MINC150) * ( (L129 = MINC150) * ( - 130) + (L129 <> MINC150) * ( (L130 = MINC150) * ( - 131) + (L130 <> MINC150) * ( (L131 = MINC150) * ( - 132) + (L131 <> MINC150) * ( (L132 = MINC150) * ( - 133) + (L132 <> MINC150) * ( (L133 = MINC150) * ( - 134) + (L133 <> MINC150) * ( (L134 = MINC150) * ( - 135) + (L134 <> MINC150) * ( (L135 = MINC150) * ( - 136) + (L135 <> MINC150) * ( (L136 = MINC150) * ( - 137) + (L136 <> MINC150) * ( (L137 = MINC150) * ( - 138) + (L137 <> MINC150) * ( (L138 = MINC150) * ( - 139) + (L138 <> MINC150) * ( (L139 = MINC150) * ( - 140) + (L139 <> MINC150) * ( (L140 = MINC150) * ( - 141) + (L140 <> MINC150) * ( (L141 = MINC150) * ( - 142) + (L141 <> MINC150) * ( (L142 = MINC150) * ( - 143) + (L142 <> MINC150) * ( (L143 = MINC150) * ( - 144) + (L143 <> MINC150) * ( (L144 = MINC150) * ( - 145) + (L144 <> MINC150) * ( (L145 = MINC150) * ( - 146) + (L145 <> MINC150) * ( (L146 = MINC150) * ( - 147) + (L146 <> MINC150) * ( (L147 = MINC150) * ( - 148) + (L147 <> MINC150) * ( (L148 = MINC150) * ( - 149) + (L148 <> MINC150) * ( (L149 = MINC150) * ( - 150) + (L149 <> MINC150) * ( (L150 = MINC150) * ( - 151) + (L150 <> MINC150) ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
diceman
Posted : Saturday, September 2, 2006 8:03:32 AM
Registered User
Joined: 1/28/2005
Posts: 6,049
Marc Moresky

Obliviously this isn't exactly the same thing but it may be something
you may find useful.

I would create a custom indicator of the percent value of the close and
150 period high.

By multiplying the answer by the smoothing period. You can create the
sum of the close and percent high.

(any simple smoothing times its period will give you its sum)
----------------------------------------------------------------------

Custom Indicator:

((MAXH150/C*100)-100)*150

(select simple smoothing 150)

----------------------------------------------------------------------
The advantage of this method is you can easily change the length of the
period you are looking at.

Change the "*150" to "*50" then change your smoothing to 50 and you
will have the sum over 50 days.

You can click on the indicator and use sort by actual value to sort a watchlist.

In the original equation if you sort the Dow stocks its easy to see that
DIS was closest to its 150 day high (over the last 150 days) and
INTC was the worst relative to its 150 day high.

Obviously this technique can be use with other type of indicators where
you want to generate a sum but also need the flexibility to adjust the
period.


Thanks
diceman
MarcM
Posted : Saturday, September 2, 2006 12:43:31 PM
Registered User
Joined: 2/27/2005
Posts: 59
Diceman, thank you for your response. I'm in the process of testing (and understanding your formula).

The problem is that I need an actual value for 'Days Since Low'. I need to calculate the Rate of Growth from the low. So if a stock grew 40% and it's low was 80 days ago..its Rate of Growth would be 40%/80 = .5%. I want to add the Rate of Growth into a PCF and use it as one of my selection criteria in a scan. I'm examining how much stocks grow, over what period of time and how fast. The Rate of Growth is the how fast. I want to be able to scan for stocks that have grown at a certain range. That's why I think I need to get the formula I included working.

If you could, do you have any ideas why it returns both positive and negative results? If you take a watchlist and sort using the formula you get confusing results. Thanks for the help.
Bruce_L
Posted : Saturday, September 2, 2006 3:04:09 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Marc Moresky,
The reason the formula switches signs is that you are multiplying negative numbers (Booleans evaluated within parentheses return -1 if True and 0 if False). If you do this an odd number of times the result is negative and if you do this an even number of times the result is positive. Another problem with the formula is that it is comparing the Lows to the Minimum Closing Price instead of to the Minimum Low.

Tanstaafl originally provided a general solution for finding days since a given Boolean returned True. The example Tanstaafl gave was simplified rather nicely by alatar, but the specifics of this simplification applied only to calculating the days since the last High or Low. I'm going back to Tanstaafl's technique, but I'm going to try and make the logic more obvious using the ABS() and NOT() functions even though it will make it longer:

ABS(Condition) * (Value) - NOT(Condition) * (
ABS(Condition1) * (Value1) - NOT(Condition1) * (
ABS(Condition2) * (Value2) - NOT(Condition2) * (
ABS(Condition3) * (Value3) - NOT(Condition3) * (
ABS(Condition4) * (Value4)
))))

Where Condition is a Boolean formula and Value is what should be assigned if the Condition is True. The Condition used in the ABS() function should be exactly the same as the Condition used in the NOT() function (this allows for creating a very complex condition without having to figure out its opposite). For example, if you wanted to count the number of days since the lowest Low in the last 5-Periods, with one being assigned if the current Period is the Low, the formula would be:

ABS(L = MINL5) * 1 - NOT(L = MINL5) * (
ABS(L1 = MINL5) * 2 - NOT(L1 = MINL5) * (
ABS(L2 = MINL5) * 3 - NOT(L2 = MINL5) * (
ABS(L3 = MINL5) * 4 - NOT(L3 = MINL5) * (
ABS(L4 = MINL5) * 5
))))

This method produces the following version of your formula:

ABS(L = MINL150) * 1 - NOT(L = MINL150) * (ABS(L1 = MINL150) * 2 - NOT(L1 = MINL150) * (ABS(L2 = MINL150) * 3 - NOT(L2 = MINL150) * (ABS(L3 = MINL150) * 4 - NOT(L3 = MINL150) * (ABS(L4 = MINL150) * 5 - NOT(L4 = MINL150) * (ABS(L5 = MINL150) * 6 - NOT(L5 = MINL150) * (ABS(L6 = MINL150) * 7 - NOT(L6 = MINL150) * (ABS(L7 = MINL150) * 8 - NOT(L7 = MINL150) * (ABS(L8 = MINL150) * 9 - NOT(L8 = MINL150) * (ABS(L9 = MINL150) * 10 - NOT(L9 = MINL150) * (ABS(L10 = MINL150) * 11 - NOT(L10 = MINL150) * (ABS(L11 = MINL150) * 12 - NOT(L11 = MINL150) * (ABS(L12 = MINL150) * 13 - NOT(L12 = MINL150) * (ABS(L13 = MINL150) * 14 - NOT(L13 = MINL150) * (ABS(L14 = MINL150) * 15 - NOT(L14 = MINL150) * (ABS(L15 = MINL150) * 16 - NOT(L15 = MINL150) * (ABS(L16 = MINL150) * 17 - NOT(L16 = MINL150) * (ABS(L17 = MINL150) * 18 - NOT(L17 = MINL150) * (ABS(L18 = MINL150) * 19 - NOT(L18 = MINL150) * (ABS(L19 = MINL150) * 20 - NOT(L19 = MINL150) * (ABS(L20 = MINL150) * 21 - NOT(L20 = MINL150) * (ABS(L21 = MINL150) * 22 - NOT(L21 = MINL150) * (ABS(L22 = MINL150) * 23 - NOT(L22 = MINL150) * (ABS(L23 = MINL150) * 24 - NOT(L23 = MINL150) * (ABS(L24 = MINL150) * 25 - NOT(L24 = MINL150) * (ABS(L25 = MINL150) * 26 - NOT(L25 = MINL150) * (ABS(L26 = MINL150) * 27 - NOT(L26 = MINL150) * (ABS(L27 = MINL150) * 28 - NOT(L27 = MINL150) * (ABS(L28 = MINL150) * 29 - NOT(L28 = MINL150) * (ABS(L29 = MINL150) * 30 - NOT(L29 = MINL150) * (ABS(L30 = MINL150) * 31 - NOT(L30 = MINL150) * (ABS(L31 = MINL150) * 32 - NOT(L31 = MINL150) * (ABS(L32 = MINL150) * 33 - NOT(L32 = MINL150) * (ABS(L33 = MINL150) * 34 - NOT(L33 = MINL150) * (ABS(L34 = MINL150) * 35 - NOT(L34 = MINL150) * (ABS(L35 = MINL150) * 36 - NOT(L35 = MINL150) * (ABS(L36 = MINL150) * 37 - NOT(L36 = MINL150) * (ABS(L37 = MINL150) * 38 - NOT(L37 = MINL150) * (ABS(L38 = MINL150) * 39 - NOT(L38 = MINL150) * (ABS(L39 = MINL150) * 40 - NOT(L39 = MINL150) * (ABS(L40 = MINL150) * 41 - NOT(L40 = MINL150) * (ABS(L41 = MINL150) * 42 - NOT(L41 = MINL150) * (ABS(L42 = MINL150) * 43 - NOT(L42 = MINL150) * (ABS(L43 = MINL150) * 44 - NOT(L43 = MINL150) * (ABS(L44 = MINL150) * 45 - NOT(L44 = MINL150) * (ABS(L45 = MINL150) * 46 - NOT(L45 = MINL150) * (ABS(L46 = MINL150) * 47 - NOT(L46 = MINL150) * (ABS(L47 = MINL150) * 48 - NOT(L47 = MINL150) * (ABS(L48 = MINL150) * 49 - NOT(L48 = MINL150) * (ABS(L49 = MINL150) * 50 - NOT(L49 = MINL150) * (ABS(L50 = MINL150) * 51 - NOT(L50 = MINL150) * (ABS(L51 = MINL150) * 52 - NOT(L51 = MINL150) * (ABS(L52 = MINL150) * 53 - NOT(L52 = MINL150) * (ABS(L53 = MINL150) * 54 - NOT(L53 = MINL150) * (ABS(L54 = MINL150) * 55 - NOT(L54 = MINL150) * (ABS(L55 = MINL150) * 56 - NOT(L55 = MINL150) * (ABS(L56 = MINL150) * 57 - NOT(L56 = MINL150) * (ABS(L57 = MINL150) * 58 - NOT(L57 = MINL150) * (ABS(L58 = MINL150) * 59 - NOT(L58 = MINL150) * (ABS(L59 = MINL150) * 60 - NOT(L59 = MINL150) * (ABS(L60 = MINL150) * 61 - NOT(L60 = MINL150) * (ABS(L61 = MINL150) * 62 - NOT(L61 = MINL150) * (ABS(L62 = MINL150) * 63 - NOT(L62 = MINL150) * (ABS(L63 = MINL150) * 64 - NOT(L63 = MINL150) * (ABS(L64 = MINL150) * 65 - NOT(L64 = MINL150) * (ABS(L65 = MINL150) * 66 - NOT(L65 = MINL150) * (ABS(L66 = MINL150) * 67 - NOT(L66 = MINL150) * (ABS(L67 = MINL150) * 68 - NOT(L67 = MINL150) * (ABS(L68 = MINL150) * 69 - NOT(L68 = MINL150) * (ABS(L69 = MINL150) * 70 - NOT(L69 = MINL150) * (ABS(L70 = MINL150) * 71 - NOT(L70 = MINL150) * (ABS(L71 = MINL150) * 72 - NOT(L71 = MINL150) * (ABS(L72 = MINL150) * 73 - NOT(L72 = MINL150) * (ABS(L73 = MINL150) * 74 - NOT(L73 = MINL150) * (ABS(L74 = MINL150) * 75 - NOT(L74 = MINL150) * (ABS(L75 = MINL150) * 76 - NOT(L75 = MINL150) * (ABS(L76 = MINL150) * 77 - NOT(L76 = MINL150) * (ABS(L77 = MINL150) * 78 - NOT(L77 = MINL150) * (ABS(L78 = MINL150) * 79 - NOT(L78 = MINL150) * (ABS(L79 = MINL150) * 80 - NOT(L79 = MINL150) * (ABS(L80 = MINL150) * 81 - NOT(L80 = MINL150) * (ABS(L81 = MINL150) * 82 - NOT(L81 = MINL150) * (ABS(L82 = MINL150) * 83 - NOT(L82 = MINL150) * (ABS(L83 = MINL150) * 84 - NOT(L83 = MINL150) * (ABS(L84 = MINL150) * 85 - NOT(L84 = MINL150) * (ABS(L85 = MINL150) * 86 - NOT(L85 = MINL150) * (ABS(L86 = MINL150) * 87 - NOT(L86 = MINL150) * (ABS(L87 = MINL150) * 88 - NOT(L87 = MINL150) * (ABS(L88 = MINL150) * 89 - NOT(L88 = MINL150) * (ABS(L89 = MINL150) * 90 - NOT(L89 = MINL150) * (ABS(L90 = MINL150) * 91 - NOT(L90 = MINL150) * (ABS(L91 = MINL150) * 92 - NOT(L91 = MINL150) * (ABS(L92 = MINL150) * 93 - NOT(L92 = MINL150) * (ABS(L93 = MINL150) * 94 - NOT(L93 = MINL150) * (ABS(L94 = MINL150) * 95 - NOT(L94 = MINL150) * (ABS(L95 = MINL150) * 96 - NOT(L95 = MINL150) * (ABS(L96 = MINL150) * 97 - NOT(L96 = MINL150) * (ABS(L97 = MINL150) * 98 - NOT(L97 = MINL150) * (ABS(L98 = MINL150) * 99 - NOT(L98 = MINL150) * (ABS(L99 = MINL150) * 100 - NOT(L99 = MINL150) * (ABS(L100 = MINL150) * 101 - NOT(L100 = MINL150) * (ABS(L101 = MINL150) * 102 - NOT(L101 = MINL150) * (ABS(L102 = MINL150) * 103 - NOT(L102 = MINL150) * (ABS(L103 = MINL150) * 104 - NOT(L103 = MINL150) * (ABS(L104 = MINL150) * 105 - NOT(L104 = MINL150) * (ABS(L105 = MINL150) * 106 - NOT(L105 = MINL150) * (ABS(L106 = MINL150) * 107 - NOT(L106 = MINL150) * (ABS(L107 = MINL150) * 108 - NOT(L107 = MINL150) * (ABS(L108 = MINL150) * 109 - NOT(L108 = MINL150) * (ABS(L109 = MINL150) * 110 - NOT(L109 = MINL150) * (ABS(L110 = MINL150) * 111 - NOT(L110 = MINL150) * (ABS(L111 = MINL150) * 112 - NOT(L111 = MINL150) * (ABS(L112 = MINL150) * 113 - NOT(L112 = MINL150) * (ABS(L113 = MINL150) * 114 - NOT(L113 = MINL150) * (ABS(L114 = MINL150) * 115 - NOT(L114 = MINL150) * (ABS(L115 = MINL150) * 116 - NOT(L115 = MINL150) * (ABS(L116 = MINL150) * 117 - NOT(L116 = MINL150) * (ABS(L117 = MINL150) * 118 - NOT(L117 = MINL150) * (ABS(L118 = MINL150) * 119 - NOT(L118 = MINL150) * (ABS(L119 = MINL150) * 120 - NOT(L119 = MINL150) * (ABS(L120 = MINL150) * 121 - NOT(L120 = MINL150) * (ABS(L121 = MINL150) * 122 - NOT(L121 = MINL150) * (ABS(L122 = MINL150) * 123 - NOT(L122 = MINL150) * (ABS(L123 = MINL150) * 124 - NOT(L123 = MINL150) * (ABS(L124 = MINL150) * 125 - NOT(L124 = MINL150) * (ABS(L125 = MINL150) * 126 - NOT(L125 = MINL150) * (ABS(L126 = MINL150) * 127 - NOT(L126 = MINL150) * (ABS(L127 = MINL150) * 128 - NOT(L127 = MINL150) * (ABS(L128 = MINL150) * 129 - NOT(L128 = MINL150) * (ABS(L129 = MINL150) * 130 - NOT(L129 = MINL150) * (ABS(L130 = MINL150) * 131 - NOT(L130 = MINL150) * (ABS(L131 = MINL150) * 132 - NOT(L131 = MINL150) * (ABS(L132 = MINL150) * 133 - NOT(L132 = MINL150) * (ABS(L133 = MINL150) * 134 - NOT(L133 = MINL150) * (ABS(L134 = MINL150) * 135 - NOT(L134 = MINL150) * (ABS(L135 = MINL150) * 136 - NOT(L135 = MINL150) * (ABS(L136 = MINL150) * 137 - NOT(L136 = MINL150) * (ABS(L137 = MINL150) * 138 - NOT(L137 = MINL150) * (ABS(L138 = MINL150) * 139 - NOT(L138 = MINL150) * (ABS(L139 = MINL150) * 140 - NOT(L139 = MINL150) * (ABS(L140 = MINL150) * 141 - NOT(L140 = MINL150) * (ABS(L141 = MINL150) * 142 - NOT(L141 = MINL150) * (ABS(L142 = MINL150) * 143 - NOT(L142 = MINL150) * (ABS(L143 = MINL150) * 144 - NOT(L143 = MINL150) * (ABS(L144 = MINL150) * 145 - NOT(L144 = MINL150) * (ABS(L145 = MINL150) * 146 - NOT(L145 = MINL150) * (ABS(L146 = MINL150) * 147 - NOT(L146 = MINL150) * (ABS(L147 = MINL150) * 148 - NOT(L147 = MINL150) * (ABS(L148 = MINL150) * 149 - NOT(L148 = MINL150) * (ABS(L149 = MINL150) * 150)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

I chose to start with one instead of zero because it allows you to place the above formula inside the Parentheses of:

100 * (C / MINL150 - 1) / (put formula here)

To get the Price Percent Change since the 150-Period Low divided by the period over which the change occurred as you described in your post (I'm not sure I'd call it the Growth Rate since it wouldn't compound to the correct overall Price Percent Change).

You could try the following for a Daily Growth Rate formula:

100 * ((C / MINL150) ^ (1 / (put formula here)) - 1)

Or the following for an Annual Growth Rate formula that seems to approximate what would be returned by the built in FX symbols:

100 * ((C / MINL150) ^ (254.427 / (put formula here)) - 1)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
diceman
Posted : Saturday, September 2, 2006 3:42:18 PM
Registered User
Joined: 1/28/2005
Posts: 6,049
Marc Moresky

I did not realize you were focused on the low.
(I thought when I read your post it was the high)
-------------------------------------------------------------------------------------------
You may want to try something like:

((C/MINL150*100)-100)*150

(with a smoothing of 150 simple)
--------------------------------------------------------------------------------------------
The lower the value the closer the stock has been to its 150 day
low. Higher mean its spent more time above the 150 day low.
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
If you are trying to find a growth rate over time . I would try this method.

Sort by:

(C30/MinL30.30*100)-100

This will give you the percent difference between the close and
minlow 30 (30 bars back in time).

You can edit the 30 length or days back I'm just using it as an example.

From what you say I would assume you want low values.

(stocks that were near their 30 bar low 30 days ago)

You would have to decide the cut-off.

Now you have a watchlist of stocks that were near their low
30 bars back.
-----------------------------------------------------------------------------------------------
I would apply a 30 bar linear regression line to the watchlist
and chose "sort by" percent slope.

Sort the watchlist in descending order.

The stocks at the top of the list have the highest "growth rate".
------------------------------------------------------------------------
In other words the "top" stocks had the best growth rate over 30 days

after being close to their 30 day low 30 days ago.


Hope that helps
Good Luck

diceman
MarcM
Posted : Monday, October 9, 2006 4:51:43 PM
Registered User
Joined: 2/27/2005
Posts: 59
I’ve been meaning to post this for the last few weeks but got distracted. Thank you for all of your help in putting together this function. What I was after was the number of days from the lowest Close in the last 150 days. This function does provide that. It works.

ABS((C0 = MINC150) * ( - 1) + (C0 <> MINC150) * ( (C1 = MINC150) * ( - 2) + (C1 <> MINC150) * ( (C2 = MINC150) * ( - 3) + (C2 <> MINC150) * ( (C3 = MINC150) * ( - 4) + (C3 <> MINC150) * ( (C4 = MINC150) * ( - 5) + (C4 <> MINC150) * ( (C5 = MINC150) * ( - 6) + (C5 <> MINC150) * ( (C6 = MINC150) * ( - 7) + (C6 <> MINC150) * ( (C7 = MINC150) * ( - 8) + (C7 <> MINC150) * ( (C8 = MINC150) * ( - 9) + (C8 <> MINC150) * ( (C9 = MINC150) * ( - 10) + (C9 <> MINC150) * ( (C10 = MINC150) * ( - 11) + (C10 <> MINC150) * ( (C11 = MINC150) * ( - 12) + (C11 <> MINC150) * ( (C12 = MINC150) * ( - 13) + (C12 <> MINC150) * ( (C13 = MINC150) * ( - 14) + (C13 <> MINC150) * ( (C14 = MINC150) * ( - 15) + (C14 <> MINC150) * ( (C15 = MINC150) * ( - 16) + (C15 <> MINC150) * ( (C16 = MINC150) * ( - 17) + (C16 <> MINC150) * ( (C17 = MINC150) * ( - 18) + (C17 <> MINC150) * ( (C18 = MINC150) * ( - 19) + (C18 <> MINC150) * ( (C19 = MINC150) * ( - 20) + (C19 <> MINC150) * ( (C20 = MINC150) * ( - 21) + (C20 <> MINC150) * ( (C21 = MINC150) * ( - 22) + (C21 <> MINC150) * ( (C22 = MINC150) * ( - 23) + (C22 <> MINC150) * ( (C23 = MINC150) * ( - 24) + (C23 <> MINC150) * ( (C24 = MINC150) * ( - 25) + (C24 <> MINC150) * ( (C25 = MINC150) * ( - 26) + (C25 <> MINC150) * ( (C26 = MINC150) * ( - 27) + (C26 <> MINC150) * ( (C27 = MINC150) * ( - 28) + (C27 <> MINC150) * ( (C28 = MINC150) * ( - 29) + (C28 <> MINC150) * ( (C29 = MINC150) * ( - 30) + (C29 <> MINC150) * ( (C30 = MINC150) * ( - 31) + (C30 <> MINC150) * ( (C31 = MINC150) * ( - 32) + (C31 <> MINC150) * ( (C32 = MINC150) * ( - 33) + (C32 <> MINC150) * ( (C33 = MINC150) * ( - 34) + (C33 <> MINC150) * ( (C34 = MINC150) * ( - 35) + (C34 <> MINC150) * ( (C35 = MINC150) * ( - 36) + (C35 <> MINC150) * ( (C36 = MINC150) * ( - 37) + (C36 <> MINC150) * ( (C37 = MINC150) * ( - 38) + (C37 <> MINC150) * ( (C38 = MINC150) * ( - 39) + (C38 <> MINC150) * ( (C39 = MINC150) * ( - 40) + (C39 <> MINC150) * ( (C40 = MINC150) * ( - 41) + (C40 <> MINC150) * ( (C41 = MINC150) * ( - 42) + (C41 <> MINC150) * ( (C42 = MINC150) * ( - 43) + (C42 <> MINC150) * ( (C43 = MINC150) * ( - 44) + (C43 <> MINC150) * ( (C44 = MINC150) * ( - 45) + (C44 <> MINC150) * ( (C45 = MINC150) * ( - 46) + (C45 <> MINC150) * ( (C46 = MINC150) * ( - 47) + (C46 <> MINC150) * ( (C47 = MINC150) * ( - 48) + (C47 <> MINC150) * ( (C48 = MINC150) * ( - 49) + (C48 <> MINC150) * ( (C49 = MINC150) * ( - 50) + (C49 <> MINC150) * ( (C50 = MINC150) * ( - 51) + (C50 <> MINC150) * ( (C51 = MINC150) * ( - 52) + (C51 <> MINC150) * ( (C52 = MINC150) * ( - 53) + (C52 <> MINC150) * ( (C53 = MINC150) * ( - 54) + (C53 <> MINC150) * ( (C54 = MINC150) * ( - 55) + (C54 <> MINC150) * ( (C55 = MINC150) * ( - 56) + (C55 <> MINC150) * ( (C56 = MINC150) * ( - 57) + (C56 <> MINC150) * ( (C57 = MINC150) * ( - 58) + (C57 <> MINC150) * ( (C58 = MINC150) * ( - 59) + (C58 <> MINC150) * ( (C59 = MINC150) * ( - 60) + (C59 <> MINC150) * ( (C60 = MINC150) * ( - 61) + (C60 <> MINC150) * ( (C61 = MINC150) * ( - 62) + (C61 <> MINC150) * ( (C62 = MINC150) * ( - 63) + (C62 <> MINC150) * ( (C63 = MINC150) * ( - 64) + (C63 <> MINC150) * ( (C64 = MINC150) * ( - 65) + (C64 <> MINC150) * ( (C65 = MINC150) * ( - 66) + (C65 <> MINC150) * ( (C66 = MINC150) * ( - 67) + (C66 <> MINC150) * ( (C67 = MINC150) * ( - 68) + (C67 <> MINC150) * ( (C68 = MINC150) * ( - 69) + (C68 <> MINC150) * ( (C69 = MINC150) * ( - 70) + (C69 <> MINC150) * ( (C70 = MINC150) * ( - 71) + (C70 <> MINC150) * ( (C71 = MINC150) * ( - 72) + (C71 <> MINC150) * ( (C72 = MINC150) * ( - 73) + (C72 <> MINC150) * ( (C73 = MINC150) * ( - 74) + (C73 <> MINC150) * ( (C74 = MINC150) * ( - 75) + (C74 <> MINC150) * ( (C75 = MINC150) * ( - 76) + (C75 <> MINC150) * ( (C76 = MINC150) * ( - 77) + (C76 <> MINC150) * ( (C77 = MINC150) * ( - 78) + (C77 <> MINC150) * ( (C78 = MINC150) * ( - 79) + (C78 <> MINC150) * ( (C79 = MINC150) * ( - 80) + (C79 <> MINC150) * ( (C80 = MINC150) * ( - 81) + (C80 <> MINC150) * ( (C81 = MINC150) * ( - 82) + (C81 <> MINC150) * ( (C82 = MINC150) * ( - 83) + (C82 <> MINC150) * ( (C83 = MINC150) * ( - 84) + (C83 <> MINC150) * ( (C84 = MINC150) * ( - 85) + (C84 <> MINC150) * ( (C85 = MINC150) * ( - 86) + (C85 <> MINC150) * ( (C86 = MINC150) * ( - 87) + (C86 <> MINC150) * ( (C87 = MINC150) * ( - 88) + (C87 <> MINC150) * ( (C88 = MINC150) * ( - 89) + (C88 <> MINC150) * ( (C89 = MINC150) * ( - 90) + (C89 <> MINC150) * ( (C90 = MINC150) * ( - 91) + (C90 <> MINC150) * ( (C91 = MINC150) * ( - 92) + (C91 <> MINC150) * ( (C92 = MINC150) * ( - 93) + (C92 <> MINC150) * ( (C93 = MINC150) * ( - 94) + (C93 <> MINC150) * ( (C94 = MINC150) * ( - 95) + (C94 <> MINC150) * ( (C95 = MINC150) * ( - 96) + (C95 <> MINC150) * ( (C96 = MINC150) * ( - 97) + (C96 <> MINC150) * ( (C97 = MINC150) * ( - 98) + (C97 <> MINC150) * ( (C98 = MINC150) * ( - 99) + (C98 <> MINC150) * ( (C99 = MINC150) * ( - 100) + (C99 <> MINC150) * ( (C100 = MINC150) * ( - 101) + (C100 <> MINC150) * ( (C101 = MINC150) * ( - 102) + (C101 <> MINC150) * ( (C102 = MINC150) * ( - 103) + (C102 <> MINC150) * ( (C103 = MINC150) * ( - 104) + (C103 <> MINC150) * ( (C104 = MINC150) * ( - 105) + (C104 <> MINC150) * ( (C105 = MINC150) * ( - 106) + (C105 <> MINC150) * ( (C106 = MINC150) * ( - 107) + (C106 <> MINC150) * ( (C107 = MINC150) * ( - 108) + (C107 <> MINC150) * ( (C108 = MINC150) * ( - 109) + (C108 <> MINC150) * ( (C109 = MINC150) * ( - 110) + (C109 <> MINC150) * ( (C110 = MINC150) * ( - 111) + (C110 <> MINC150) * ( (C111 = MINC150) * ( - 112) + (C111 <> MINC150) * ( (C112 = MINC150) * ( - 113) + (C112 <> MINC150) * ( (C113 = MINC150) * ( - 114) + (C113 <> MINC150) * ( (C114 = MINC150) * ( - 115) + (C114 <> MINC150) * ( (C115 = MINC150) * ( - 116) + (C115 <> MINC150) * ( (C116 = MINC150) * ( - 117) + (C116 <> MINC150) * ( (C117 = MINC150) * ( - 118) + (C117 <> MINC150) * ( (C118 = MINC150) * ( - 119) + (C118 <> MINC150) * ( (C119 = MINC150) * ( - 120) + (C119 <> MINC150) * ( (C120 = MINC150) * ( - 121) + (C120 <> MINC150) * ( (C121 = MINC150) * ( - 122) + (C121 <> MINC150) * ( (C122 = MINC150) * ( - 123) + (C122 <> MINC150) * ( (C123 = MINC150) * ( - 124) + (C123 <> MINC150) * ( (C124 = MINC150) * ( - 125) + (C124 <> MINC150) * ( (C125 = MINC150) * ( - 126) + (C125 <> MINC150) * ( (C126 = MINC150) * ( - 127) + (C126 <> MINC150) * ( (C127 = MINC150) * ( - 128) + (C127 <> MINC150) * ( (C128 = MINC150) * ( - 129) + (C128 <> MINC150) * ( (C129 = MINC150) * ( - 130) + (C129 <> MINC150) * ( (C130 = MINC150) * ( - 131) + (C130 <> MINC150) * ( (C131 = MINC150) * ( - 132) + (C131 <> MINC150) * ( (C132 = MINC150) * ( - 133) + (C132 <> MINC150) * ( (C133 = MINC150) * ( - 134) + (C133 <> MINC150) * ( (C134 = MINC150) * ( - 135) + (C134 <> MINC150) * ( (C135 = MINC150) * ( - 136) + (C135 <> MINC150) * ( (C136 = MINC150) * ( - 137) + (C136 <> MINC150) * ( (C137 = MINC150) * ( - 138) + (C137 <> MINC150) * ( (C138 = MINC150) * ( - 139) + (C138 <> MINC150) * ( (C139 = MINC150) * ( - 140) + (C139 <> MINC150) * ( (C140 = MINC150) * ( - 141) + (C140 <> MINC150) * ( (C141 = MINC150) * ( - 142) + (C141 <> MINC150) * ( (C142 = MINC150) * ( - 143) + (C142 <> MINC150) * ( (C143 = MINC150) * ( - 144) + (C143 <> MINC150) * ( (C144 = MINC150) * ( - 145) + (C144 <> MINC150) * ( (C145 = MINC150) * ( - 146) + (C145 <> MINC150) * ( (C146 = MINC150) * ( - 147) + (C146 <> MINC150) * ( (C147 = MINC150) * ( - 148) + (C147 <> MINC150) * ( (C148 = MINC150) * ( - 149) + (C148 <> MINC150) * ( (C149 = MINC150) * ( - 150) + (C149 <> MINC150) * ( (C150 = MINC150) * ( - 151) + (C150 <> MINC150) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
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.