Subscription & data-feed pricing Class schedule

Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.

 Using Linear Regression vs Classical Peaks/Valleys for Divergence Analysis Topic Rating:
 Previous Topic · Next Topic Watch this topic · Print this topic ·
Tanstaafl
 Posted : Monday, December 13, 2004 6:56:36 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA

## Please see the Linear Regression and Linear Regression Slope topic for improved syntax in TC2000 v17+.

It's been my observation that although many books and articles make use of divergences, few actually define their construction, and none that I am aware of any that prove why (if at all) the classic method by which they are determined is the best (or only good) way to do it. All the info seems to be in the category of "it works, so use it". So, I thot maybe some of you might be interested in pursuing this topic in a bit more depth.

I'll start with a brief and not very precise description of two different methods for identifying divergences:

*******

1) Peaks & Valleys Method: this is the classic approach. Manually draw lines on Price and on Indicator anchored by recent successive, definitive, and approximately co-temporal pivots. Use peaks of price and indicator during uptrends, and valleys of both during downtrends.

2) Linear Regression Method: convenient for automated searches since it is relatively easy to formulae for scans. Lines are based on least-squares LinReg straight-line fits to an arbitrary time window of the Price and the Indicator.

In each case, the lines are interpreted on the theory that the slope of the Indicator's line gives a hint of future price action - either the end of a current run, a reversal, or the initiation of a new one.

a) Bearish prediction during a downtrend: slope of price line is up, but slope of indicator is down.
b) Bullish prediction during an uptrend: slope of price line is down, but slope of indicator is up.

*******

There are a whole lot of aspects of these methods that are subjective. Here are some general things to consider before making a firm decision about which is best to use:

------------

A. In the classic method, the one highly-subjective variable is deciding *which* peaks and valleys to base the lines on. Seems to me that eyeball + brain using the SBAS (Step Back And Squint) approach is the norm.

-------------

B. In the LinReg method, the most subjective aspect is probably the selection of how large a time window should be used in the creation of the LinReg lines. I tend to base it on the my typical position hold-time, or some simple multiple of it.

-------------

C. To what degree is divergence analysis dependent on an extant trend? This is a trick question, since trends can be defined on many different levels (barlenths) ... so the inter-relation of trend definition and the period over which the lines are created (or the peaks/valleys are evaluated) should be carefull considered.

--------------

D. Since the slopes of the Price and Indicator lines are on (necessarily) different scales, we need a means to judge the "strength" of divergences between several different symbols, without relying on angles that change with zoom, etc. I've got some ideas about this that I will post later.

--------------

E. Price divergence-lines themselves (or some channel around them) can be used as a secondary timing threshold that, once crossed, indicates the initiative of the new direction. TC makes this very easy with its LinReg Channel lines.

-------------

F. For some situations, especially with very "choppy" prices &/or indicators, it's better to create divergence lines on a 3-bar-XMA-smoothed version of the raw values.

--------------

G. Which indicators are most effective for divergence analysis? Sure, everybody has an opinion ... but providing some kind of logical or mathematical rationale would be comforting!

===========

Probably many more subtopics could be added to this list. I would enjoy discussing these topics if any of you are interested.

Tanstaafl
 Posted : Monday, December 13, 2004 7:10:42 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
For those of you who are unfamiliar with Divergence logic, here is the general form:

Bullish (positive) divergence (reverse the </> operators for Bearish) :
LinRegSlope(indicator) > 0
and
LinRegSlope(price) < 0

Here's a nifty way to create a single PCF that produces a +1 result for a Bull divergence, a -1 result for a Bear divergence, and a zero if no divergence currently exists:

( LinRegSlope(indicator) < 0 and LinRegSlope(price) > 0 )
- ( LinRegSlope(indicator) > 0 and LinRegSlope(price) < 0 )

You should plug in the formula for the appropriate LRS (LinRegSlope), using the technique outlined below:

Linear Regression: (Best-Fit Line) Slope and Value formulae:

General Construction Rules:
... based on series Fac0*C0 + Fac1*C1 + ...
...... list of Fac's always stairs down then up
... Prior DayFac = This DayFac -1
...... Initial C0 TodayFac = Pds/2 - 0.5
...... odd-# LinReg's middle-day Fac = 0
Fac-List Examples (using rules above)
2-Day LinReg: Fac0= 0.5, Fac1= -0.5
3-Day LinReg: Fac0= 1.0, Fac2= -1.0
4-Day: F0= 1.5, F1= 0.5, F2= -0.5, F3= -1.5
5-Day: F0= 2.0, F1= 1.0, F3= -1.0, F3= -2.0
6-Day: F0-F6= 2.5, 1.5, 0.5, -0.5, -1.5, -2.5
7-Day: F0-F7= 3, 2, 1, 0, -1, -2, -3
8-Day: 3.5, 2.5, 1.5, 0.5, -0.5, -1.5, -2.5, -3.5

LRSlope (positive=up, negative=down)
... Direction: Sgn(Fac0*C0 + Fac1*C1 ...)
...... this slope value is not true &/day
... True: (Fac0*C0 + Fac1*C1 ...) / Denom
...... Denom = complex formula, so plug in:
LRpds=Denom List: 2=0.5, 3=2, 4=5, 5=10,
6=17.5, 7=28, 8=42, 9=60, 10=82.5, 11=110,
12=143, 13=182, 14=227.5, 15=280, 16=340
17=408, 18=484.5, 19=570, 20=665, 21=770
22=885.5, 23=1012, 24=1150, 25=1300,
26=1462.5, 27=1638, 28=1827, 29=2030,
30=2247.5, 34=3272.5, 40=5530

5-day LinReg True-Slope of Close example:
( 2*C0 +1*C1 +0*C2 -1*C3 -2*C4 ) / 10

LRValue (for a given bar on the Line)
... LRV(day) = (LRSlope*DayFac) + Base
...... DayFac(day) = Fac0 + day, where
...... right end day = 0, left end = LRpds
...... 3 days in future (right of end) = -3
...... Base = AvgCn, where n = LRpds

Tomorrow-Val for 5-day LinReg of Close:
( 2*C0 +1*C1 +0*C2 -1*C3 -2*C4 ) / 10
* ( 2 + (-1) ) + AvgC5

Tanstaafl
 Posted : Monday, December 13, 2004 7:12:49 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
The PCF-based methodology I use for divergences incorporates several neat ways of evaluating the "strength" of the divergence, once the formulae attached at the end of this writeup have been used to identify the slope direction.

This method has several strengths, in particular:

** Its basis is the simplest core form of the LinReg math (+/- slope-direction), keeping the PCF's relatively short and efficient

** It is relatively easy to adjust for different time windows and trading styles

** It can be adapted to Custom Indicator form and be visually backtested as such

** It is independent of the actual values or scaling of the indicator and of the symbol's price

** Its ranking approach is simple to understanding and work with

Here is the approach, in a nutshell:

1) Write a T/F PCF that identifies price-vs-indicator divergences using the info attached to the end of this document - this requires two formulae with appropriate glue-logic

2) Copy and modify the #1 PCF to model the same two LinReg lines, but change the "anchor" point from today to N days ago (typically N might be half of the LinReg window)

3) Copy and modify the #1 PCF to model the same two LinReg lines, but lengthen the "window width" to M days, anchored to today (typically M might be 2x the width of the #1 formulae)

4) Combine these formulae with boolean-algebra logic that:
a. identifies the divergence based on #1, giving it a "score" of +100 for bullish, -10 for bearish, or 0 otherwise
b. adds +10/0/-10 to the score based on a similar divergence eval from the #2 N-days-ago formulae
c. adds +1/0/-1 to the score based on a similar divergence eval from the #3 M-days-wide formulae

Plot the result as a Custom Indicator (for visual backtesting), or assign it to a WL tab column for daily use. The 100/10/1 weighted "score" components can be interchanged if you wish.

Answers can be +111, +110, +109, +101, +100, +99, +90, +10, +9, +1, 0 or their negative equivalents. By assigning this in a "decimal tiered" fashion, you not only get a nicely sortable result, but also can quickly see which of the criteria had "hits".

You could also create a fourth component, which would combine #2 and #3 to create a M-days wide, N-days ago check. I have found this to add little benefit, however - it has a lot of lag in it. If so, I suggest you give it a score-adder of +0.1/0/-0.1

OK ... for those of you who are pretty good at PCF's, this gives you the "heart" of the methodology. You should be able to take it from here. I'll be happy to help out if there are any questions.

Jim Dean

jacquesM
 Posted : Saturday, January 22, 2005 4:26:52 PM
Registered User
Joined: 10/7/2004
Posts: 3
Sorry for my English

I Think That you can have an other type of divergence.
A bullish prediction during a consolidation : Slope price line Up and Slope of indicator Down.
Stoch. and RSI are good for that type of divergence.
JacquesM
Tanstaafl
 Posted : Saturday, January 22, 2005 5:26:04 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, Jacques:

It may be that with some indicator settings the combination that you mentioned gives bullish indications, BUT ... the example you provided is in fact a case of BEARISH divergence, if you use the "classic" definition of "divergence".

"Classic" divergence says that the INDICATOR LEADS THE PRICE ... that is, the slope of the indicator's line "predicts the future" of the slope of the Price line.

Of course, this prediction does not always work out to be true!

Jim Dean

jacquesM
 Posted : Saturday, January 22, 2005 10:10:06 PM
Registered User
Joined: 10/7/2004
Posts: 3
Hi, Jim:

I am aware that I was not speaking about classic definition of divergence.

I use linear regression since 2002 for entry point only. To be clear I use three parameters: price, volume and three linears regression of two indicators.

I use the pure indicator.
I use the indicator with the ROC like filter.
And I use the indicator with the MA like filter.

Without linear regression lines I can't work.

Thank you
JacquesM
Tanstaafl
 Posted : Tuesday, January 25, 2005 8:53:58 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA

Tanstaafl
 Posted : Sunday, March 20, 2005 2:30:06 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
For completeness, here is a link to a contribution that Bruce has made to this solution, which provides PCF info that solves the LinReg CHANNEL value calc (please note that TC's LinReg Channel width is NOT based on "standard deviation" math)

Linear regression channel calculations

bustermu
 Posted : Tuesday, April 4, 2006 12:12:34 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
This thread is the standard reference for Linear Regression (LR) PCFs. Our purpose is to give general forms for Linear Regression Slope (LRSlope) and Linear Regression Moving Average (LRMA).

A portion of Jim Dean's post is reproduced here for easy reference.

______________________________

Linear Regression: (Best-Fit Line) Slope and Value formulae:

General Construction Rules:
... based on series Fac0*C0 + Fac1*C1 + ...
...... list of Fac's always stairs down then up
... Prior DayFac = This DayFac -1
...... Initial C0 TodayFac = Pds/2 - 0.5
...... odd-# LinReg's middle-day Fac = 0
Fac-List Examples (using rules above)
2-Day LinReg: Fac0= 0.5, Fac1= -0.5
3-Day LinReg: Fac0= 1.0, Fac2= -1.0
4-Day: F0= 1.5, F1= 0.5, F2= -0.5, F3= -1.5
5-Day: F0= 2.0, F1= 1.0, F3= -1.0, F3= -2.0
6-Day: F0-F6= 2.5, 1.5, 0.5, -0.5, -1.5, -2.5
7-Day: F0-F7= 3, 2, 1, 0, -1, -2, -3
8-Day: 3.5, 2.5, 1.5, 0.5, -0.5, -1.5, -2.5, -3.5

LRSlope (positive=up, negative=down)
... Direction: Sgn(Fac0*C0 + Fac1*C1 ...)
...... this slope value is not true &/day
... True: (Fac0*C0 + Fac1*C1 ...) / Denom
...... Denom = complex formula, so plug in:
LRpds=Denom List: 2=0.5, 3=2, 4=5, 5=10,
6=17.5, 7=28, 8=42, 9=60, 10=82.5, 11=110,
12=143, 13=182, 14=227.5, 15=280, 16=340
17=408, 18=484.5, 19=570, 20=665, 21=770
22=885.5, 23=1012, 24=1150, 25=1300,
26=1462.5, 27=1638, 28=1827, 29=2030,
30=2247.5, 34=3272.5, 40=5530

5-day LinReg True-Slope of Close example:
( 2*C0 +1*C1 +0*C2 -1*C3 -2*C4 ) / 10

LRValue (for a given bar on the Line)
... LRV(day) = (LRSlope*DayFac) + Base
...... DayFac(day) = Fac0 + day, where
...... right end day = 0, left end = LRpds
...... 3 days in future (right of end) = -3
...... Base = AvgCn, where n = LRpds

Tomorrow-Val for 5-day LinReg of Close:
( 2*C0 +1*C1 +0*C2 -1*C3 -2*C4 ) / 10
* ( 2 + (-1) ) + AvgC5

______________________________

We will use the above notation except that P is used for the LR Period.

The formula for Fack is:

Fack = (P-1)/2-k, k = 0, 1, 2, ..., (P-1)

Notice that the Fac's always stair down, not up.

The form:

Fac0*C0+Fac1*C1+...+Fac(P-1)*C(P-1)

has the same sign as LRSlope if that is all you are interested in.

The Denom is given by:

Denom = P*(P^2-1)/12

or, equivalently, by:

Denom = (P-1)*P*(P +1)/12

The LRSlope is:

(Fac0*C0+Fac1*C1+fac2*C2+...+Fac(P-1)*C(P-1))/(P*(P^2-1)/12)

The LRMA is:

AVGCP + Fac0*LRSlope

The only missing part of Jim Dean's post is the formula for Denom. The value of Denom for P = 40 is 5330 not 5530 as given.

While we are dealing with LRSlope, it may be of interest to know that the Weighted Moving Average of Period P (WMAP) is given by:

WMAP = AVGCP + ((P-1)/6)*LRSlopeP

Thanks,
Jim Murphy
nithiya01
 Posted : Tuesday, October 30, 2007 2:56:32 PM
Registered User
Joined: 4/25/2007
Posts: 30
hi
can anyone tell me how draw a manual line on the indicators please
thank you
Bruce_L
 Posted : Tuesday, October 30, 2007 3:08:10 PM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
nithiya01,
You may wish to review the following for information on adding Drawing Tools to your chart:

Drawing Trendlines, Regressions and Writing Notes on a chart

Drawing Tools may only be used in the top Pane and are always scaled with Price.

You may add a Linear Regression Indicator as a Child Indicator by selecting Chart Template | Add Indicator | Linear Regression and then choosing the Parent Indicator. You may wish to review the following:

Adding, removing and saving indicators to a chart template

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jfh123
 Posted : Friday, November 16, 2007 10:18:23 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Tanstaafl)
The PCF-based methodology I use for divergences incorporates several neat ways of evaluating the "strength" of the divergence, once the formulae attached at the end of this writeup have been used to identify the slope direction.

This method has several strengths, in particular:

** Its basis is the simplest core form of the LinReg math (+/- slope-direction), keeping the PCF's relatively short and efficient

** It is relatively easy to adjust for different time windows and trading styles

** It can be adapted to Custom Indicator form and be visually backtested as such

** It is independent of the actual values or scaling of the indicator and of the symbol's price

** Its ranking approach is simple to understanding and work with

Here is the approach, in a nutshell:

1) Write a T/F PCF that identifies price-vs-indicator divergences using the info attached to the end of this document - this requires two formulae with appropriate glue-logic

2) Copy and modify the #1 PCF to model the same two LinReg lines, but change the "anchor" point from today to N days ago (typically N might be half of the LinReg window)

3) Copy and modify the #1 PCF to model the same two LinReg lines, but lengthen the "window width" to M days, anchored to today (typically M might be 2x the width of the #1 formulae)

4) Combine these formulae with boolean-algebra logic that:
a. identifies the divergence based on #1, giving it a "score" of +100 for bullish, -10 for bearish, or 0 otherwise
b. adds +10/0/-10 to the score based on a similar divergence eval from the #2 N-days-ago formulae
c. adds +1/0/-1 to the score based on a similar divergence eval from the #3 M-days-wide formulae

Plot the result as a Custom Indicator (for visual backtesting), or assign it to a WL tab column for daily use. The 100/10/1 weighted "score" components can be interchanged if you wish.

Answers can be +111, +110, +109, +101, +100, +99, +90, +10, +9, +1, 0 or their negative equivalents. By assigning this in a "decimal tiered" fashion, you not only get a nicely sortable result, but also can quickly see which of the criteria had "hits".

You could also create a fourth component, which would combine #2 and #3 to create a M-days wide, N-days ago check. I have found this to add little benefit, however - it has a lot of lag in it. If so, I suggest you give it a score-adder of +0.1/0/-0.1

OK ... for those of you who are pretty good at PCF's, this gives you the "heart" of the methodology. You should be able to take it from here. I'll be happy to help out if there are any questions.

Jim Dean

Jim,

Thanks for this posting.  Between postings by you and BruceL, and perhaps others, I have learned how to write a PCF that tells when the slope (of a LinReg of Price) goes from positive to negative.  But, when I use the same methodology to calculate the slope of a LinReg of OBV, it says I can't divide by zero (perhaps because OBV can be negative, and the LinReg slope equation uses EXP?).

Would you help me with an equation that calculates the slope of a LinReg of OBV?  It needs to be calculated in a manner which will also work to calculate the slope of the LinReg of price, so I can compare the two.

Thanks!

J
Bruce_L
 Posted : Monday, November 19, 2007 1:20:53 PM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jfh123,
If I were writing a formula for the Annulized Price Growth Rate using a 10-Period Linear Regression on Daily charts, it would look like:

100 * (EXP(253 * (4.5 * LOG(C ) + 3.5 * LOG(C1) + 2.5 * LOG(C2) + 1.5 * LOG(C3) + .5 * LOG(C4) - .5 * LOG(C5) - 1.5 * LOG(C6) - 2.5 * LOG(C7) - 3.5 * LOG(C8) - 4.5 * LOG(C9)) / 82.5) - 1)

If I were just writing a formula for the Slope of the 10-Period Linear Regression of Price on Daily Arithmetic charts, it would look like the following instead:

(4.5 * C + 3.5 * C1 + 2.5 * C2 + 1.5 * C3 + .5 * C4 - .5 * C5 - 1.5 * C6 - 2.5 * C7 - 3.5 * C8 - 4.5 * C9) / 82.5

The primary difference is that the first would be based on a straight line on a Logarithmic chart and is displayed as a Percentage per Year while the second would be a straight line on an Arithmetic chart and is expressed as dollars per bar. Because you really can't chart something that crosses down through zero on a Logarithmic chart, you would probably want to use the second form for OBV:

(4.5 * OBV + 3.5 * OBV1.1 + 2.5 * OBV1.2 + 1.5 * OBV1.3 + .5 * OBV1.4 - .5 * OBV1.5 - 1.5 * OBV1.6 - 2.5 * OBV1.7 - 3.5 * OBV1.8 - 4.5 * OBV1.9) / 82.5

You could write a formula for when the slope crosses down through zero as follows:

4.5 * OBV + 3.5 * OBV1.1 + 2.5 * OBV1.2 + 1.5 * OBV1.3 + .5 * OBV1.4 - .5 * OBV1.5 - 1.5 * OBV1.6 - 2.5 * OBV1.7 - 3.5 * OBV1.8 - 4.5 * OBV1.9 < 0 AND 4.5 * OBV1.1 + 3.5 * OBV1.2 + 2.5 * OBV1.3 + 1.5 * OBV1.4 + .5 * OBV1.5 - .5 * OBV1.6 - 1.5 * OBV1.7 - 2.5 * OBV1.8 - 3.5 * OBV1.9 - 4.5 * OBV1.10 >= 0

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jfh123
 Posted : Friday, December 21, 2007 10:37:31 AM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Tanstaafl)

5-day LinReg True-Slope of Close example:
( 2*C0 +1*C1 +0*C2 -1*C3 -2*C4 ) / 10

LRValue (for a given bar on the Line)
... LRV(day) = (LRSlope*DayFac) + Base
...... DayFac(day) = Fac0 + day, where
...... right end day = 0, left end = LRpds
...... 3 days in future (right of end) = -3
...... Base = AvgCn, where n = LRpds

Tomorrow-Val for 5-day LinReg of Close:
( 2*C0 +1*C1 +0*C2 -1*C3 -2*C4 ) / 10
* ( 2 + (-1) ) + AvgC5

Jim,

I see your name so often, next to the solution, whenever I'm trying to solve a difficult problem.  Thanks for all that!

I am trying to use LinReg's for pattern recognition, and I think this posting by you has lots of what I'll need.  I was able to cut & paste your " 5-day LinReg True-Slope of Close example", then see I'd done so correctly by comparing the calculated slope to a 5-pd LinReg line.  So far, so good.

But, when I tried the same with your "Tomorrow-Val for 5-day LinReg of Close", I don't see any comfort that I did it correctly.  I assumed a 5pd LinReg, with a 1pd extension, would end at the same place as an Indicator with your formula in it.  But, for 11/30/87 (no special importance to that day) the LinReg+Extn forecasts about 242, while the Indicator (blue) is 237.68.  I tried (without success, so far) to attach a piture of what I am seeing).  Help?
cdj001
 Posted : Tuesday, November 22, 2011 11:22:53 AM
Registered User
Joined: 10/28/2011
Posts: 4
Hi Bruce:
Can you provide some PCFs for the ideas Quoted Below? I can not find a way to write up this in TC 2000.
It seems that in the TC2000 there is no way to write up a designing-a-score PCF as Indicator or Condition, it this true?

QUOTE (Tanstaafl)
The PCF-based methodology I use for divergences incorporates several neat ways of evaluating the "strength" of the divergence, once the formulae attached at the end of this writeup have been used to identify the slope direction.

This method has several strengths, in particular:

** Its basis is the simplest core form of the LinReg math (+/- slope-direction), keeping the PCF's relatively short and efficient

** It is relatively easy to adjust for different time windows and trading styles

** It can be adapted to Custom Indicator form and be visually backtested as such

** It is independent of the actual values or scaling of the indicator and of the symbol's price

** Its ranking approach is simple to understanding and work with

Here is the approach, in a nutshell:

1) Write a T/F PCF that identifies price-vs-indicator divergences using the info attached to the end of this document - this requires two formulae with appropriate glue-logic

2) Copy and modify the #1 PCF to model the same two LinReg lines, but change the "anchor" point from today to N days ago (typically N might be half of the LinReg window)

3) Copy and modify the #1 PCF to model the same two LinReg lines, but lengthen the "window width" to M days, anchored to today (typically M might be 2x the width of the #1 formulae)

4) Combine these formulae with boolean-algebra logic that:
a. identifies the divergence based on #1, giving it a "score" of +100 for bullish, -10 for bearish, or 0 otherwise
b. adds +10/0/-10 to the score based on a similar divergence eval from the #2 N-days-ago formulae
c. adds +1/0/-1 to the score based on a similar divergence eval from the #3 M-days-wide formulae

Plot the result as a Custom Indicator (for visual backtesting), or assign it to a WL tab column for daily use. The 100/10/1 weighted "score" components can be interchanged if you wish.

Answers can be +111, +110, +109, +101, +100, +99, +90, +10, +9, +1, 0 or their negative equivalents. By assigning this in a "decimal tiered" fashion, you not only get a nicely sortable result, but also can quickly see which of the criteria had "hits".

You could also create a fourth component, which would combine #2 and #3 to create a M-days wide, N-days ago check. I have found this to add little benefit, however - it has a lot of lag in it. If so, I suggest you give it a score-adder of +0.1/0/-0.1

OK ... for those of you who are pretty good at PCF's, this gives you the "heart" of the methodology. You should be able to take it from here. I'll be happy to help out if there are any questions.

Jim Dean
Bruce_L
 Posted : Tuesday, November 22, 2011 12:03:16 PM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (cdj001)
It seems that in the TC2000 there is no way to write up a designing-a-score PCF as Indicator or Condition, it this true?

No, it is not true.

PCF Formula Descriptions

Placing a Boolean expression inside parentheses will return -1 for True or 0 for False when it is part of a larger value based formula.

Placing a Boolean expression inside an ABS() function will return 1 for True or 0 for False when it is part of a larger value based formula.

So the basic structure would generally be (note that this is not an actual formula):

weight_1 * ABS(boolean_expression_1) + weight_2 * ABS(boolean_expression_2) + weight_3 * ABS(boolean_expression_3)

QUOTE (cdj001)
Can you provide some PCFs for the ideas Quoted Below?

The following adds 100 if the 10-Period Linear Regression Slope is positive while the 10-Period Linear Regression Slope of MoneyStream is negative, subtracts 100 if the 10-Period Linear Regression Slope is negative while the 10-Period Linear Regression Slope of MoneyStream is positive, adds 10 if the 10-Period Linear Regression Slope of 5-Bars Ago is positive while the 10-Period Linear Regression Slope of 5-Bars Ago of MoneyStream is negative, subtracts 10 if the 10-Period Linear Regression Slope of 5-Bars Ago is negative while the 10-Period Linear Regression Slope of 5-Bars Ago of MoneyStream is positive, adds 1 if the 20-Period Linear Regression Slope is positive while the 20-Period Linear Regression Slope of MoneyStream is negative and subtracts 1 if the 10-Period Linear Regression Slope is negative while the 10-Period Linear Regression Slope of MoneyStream is positive:

100 * SGN(9 * (C - C9) + 7 * (C1 - C8) + 5 * (C2 - C7) + 3 * (C3 - C6) + C4 - C5) * ABS(SGN(9 * (C - C9) + 7 * (C1 - C8) + 5 * (C2 - C7) + 3 * (C3 - C6) + C4 - C5) + SGN(9 * (MS - MS1.9) + 7 * (MS1.1 - MS1.8) + 5 * (MS1.2 - MS1.7) + 3 * (MS1.3 - MS1.6) + MS1.4 - MS1.5) = 0) + 10 * SGN(9 * (C5 - C14) + 7 * (C6 - C13) + 5 * (C7 - C12) + 3 * (C8 - C11) + C9 - C10) * ABS(SGN(9 * (C5 - C14) + 7 * (C6 - C13) + 5 * (C7 - C12) + 3 * (C8 - C11) + C9 - C10) + SGN(9 * (MS1.5 - MS1.14) + 7 * (MS1.6 - MS1.13) + 5 * (MS1.7 - MS1.12) + 3 * (MS1.8 - MS1.11) + MS1.9 - MS1.10) = 0) + SGN(19 * (C - C19) + 17 * (C1 - C18) + 15 * (C2 - C17) + 13 * (C3 - C16) + 11 * (C4 - C15) + 9 * (C5 - C14) + 7 * (C6 - C13) + 5 * (C7 - C12) + 3 * (C8 - C11) + C9 - C10) * ABS(SGN(19 * (C - C19) + 17 * (C1 - C18) + 15 * (C2 - C17) + 13 * (C3 - C16) + 11 * (C4 - C15) + 9 * (C5 - C14) + 7 * (C6 - C13) + 5 * (C7 - C12) + 3 * (C8 - C11) + C9 - C10) + SGN(19 * (MS - MS1.19) + 17 * (MS1.1 - MS1.18) + 15 * (MS1.2 - MS1.17) + 13 * (MS1.3 - MS1.16) + 11 * (MS1.4 - MS1.15) + 9 * (MS1.5 - MS1.14) + 7 * (MS1.6 - MS1.13) + 5 * (MS1.7 - MS1.12) + 3 * (MS1.8 - MS1.11) + MS1.9 - MS1.10) = 0)

It's basic format is (again, this is not a formula):

100 * SGN(LRS(C,10)) * ABS(SGN(LRS(C,10)) + SGN(LRS(MS,10))) + 10 * SGN(LRS(C5,10)) * ABS(SGN(LRS(C5,10)) + SGN(LRS(MS1.5,10))) + SGN(LRS(C,20)) * ABS(SGN(LRS(C,20)) + SGN(LRS(MS,20)))

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
cdj001
 Posted : Tuesday, November 22, 2011 1:30:25 PM
Registered User
Joined: 10/28/2011
Posts: 4

Wonderful! Bruce, you are great! This helps me a lot, thank you very much!

jwgrant
 Posted : Friday, December 20, 2013 6:18:17 AM
Registered User
Joined: 5/20/2010
Posts: 1

The discussion, knowledge, and technical detail offered by the people commenting on this topic is very impressive.

However, it strikes me that the vast majority of this detail could be avoided if the TC2000 programmers would make another PCF variable available to users that is the MLR (moving linear regression). The name of the variable would look something like this: MLRC30.4. That would be the value 4 days ago of the predicted value for that day of the linear regression of the closing price over the prior 30 days.

It seems that the divergence between the MLRC30.4 and the actual closing price would then be a simple matter to calculate.

Bruce_L
 Posted : Friday, December 20, 2013 9:41:01 AM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138

It should probably be noted that it is relatively easy to scan for divergences as defined by linear regression slope, percent change or net change in TC2000 version 12.4 without creating any formulas at all.

You can add the indicators you to check for divergences to the chart.

Then click on those indicators and select Create Scan Condition. You will want to create a Moving Up condition for one of the indicators and a Moving Down condition for the other indicator. You would set the period to the number of bars over which you want to find a divergence and use the same period for both indicators.

The choice of which Moving Up or Moving Down condition to choose (Net, % or Smart) is up to you, but you should not use the % versions of these conditions if the indicator in question can be equal to or cross through zero.

If you are interested in using Linear Regression Slope for this instead of using the change in the indicator itself, you would add Linear Regression Line indicators to both of the indicators you wanted to compare with the period of the Linear Regression Line indicator.

You would then click on the Linear Regression Line indicators to create your Moving Up and Moving Down conditions instead of clicking on the indicators to which the Linear Regression Line indicators are applied. You will want to the set periods of the Moving Up and Moving Down conditions you are creating to 1.

Once you have the two conditions you are going to use to compare the two indicators, you will add them to the same EasyScan as EasyScan Conditions. The EasyScan will then return a list of symbols in its List to Scan which meet the requirements of all of the conditions in the EasyScan.

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

 Forum Jump Customer Training & Support - Ask a Trainer - TC2000 version 12/18 - Ask a Trainer - TC2000 version 7 - Ask a Trainer - StockFinder 5.0 - PCFs, EasyScan and Custom Indicators General Discussions - Stock and Market Talk - TC2000 version 12 or 18 - TC2000 version 7 - StockFinder 5.0 - RealCode for StockFinder 5.0 Tutorial Videos - TC2000 version 12 tutorial videos - TC2000 version 7 tutorial videos 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.