TC2000.com• Download software • Tutorial videos • Subscription & data-feed pricing • Class schedule
TC2000Brokerage.com• New account application • Trading resources • Margin rates • Stock & option commissions
Worden Discussion Forum » Customer Training & Support » PCFs, EasyScan and Custom Indicators » Using Linear Regression vs Classical Peaks/Valleys for Divergence Analysis
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.
Wonderful! Bruce, you are great! This helps me a lot, thank you very much!
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.
Thank you for your suggestion.
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.
Webinar: EasyScans for Your Favorite Setups - Breakouts, Consolidations & Divergences
You can add the indicators you to check for divergences to the chart.
Adding and Moving Indicators
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.
Create Conditions from Your Chart
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.
Building a Scan with Multiple Conditions