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 |

Applying a Moving Average to a Moving Linear Regression Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Tanstaafl
Posted : Wednesday, June 22, 2005 6:53:28 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Copyright 2005 by James D. Dean, all rights reserved

At this time, if you plot a MovAvg and then apply a LinReg child to it, you can see the plot on the screen. But if you plot a Moving LinReg first, then hang a MovAvg child off it (without using the internal smoothing), the child is invisible - as are any OTHER child indicators of a MovLinReg.

You can solve the problem in two ways. The awkard one is to plot the MovLinReg as a Custom Indicator, then apply smoothing to that either within the CI spec or as a child that you hang off it. More info about constructing Linear Regressions as Custom Indicators can be found at:
Using Linear Regression vs Classical Peaks/Valleys for Divergence Analysis and Linear regression channel calculations

HOWEVER, the best solution is MUCH SIMPLER, and more elegant. You will find that mathematically, and when plotted, the LinReg(MovAvg) is the same exact line and value as the MovAvg(LinReg). This applies to LinReg values or LinReg slopes. It applies to Moving LinRegs or static ones. It applies to any form of Moving Averages that I normally would use with TC: Simple, Exponential, Wilders, Weighted.

This can be demonstrated by plotting the following LinReg50 Custom Indicator using the Price scale on the top pane:
( 24.5*C0 +23.5*C1 +22.5*C2 +21.5*C3 +20.5*C4 +19.5*C5 +18.5*C6 +17.5*C7 +16.5*C8 +15.5*C9 +14.5*C10 +13.5*C11 +12.5*C12 +11.5*C13 +10.5*C14 +9.5*C15 +8.5*C16 +7.5*C17 +6.5*C18 +5.5*C19 +4.5*C20 +3.5*C21 +2.5*C22 +1.5*C23 +0.5*C24 -0.5*C25 -1.5*C26 -2.5*C27 -3.5*C28 -4.5*C29 -5.5*C30 -6.5*C31 -7.5*C32 -8.5*C33 -9.5*C34 -10.5*C35 -11.5*C36 -12.5*C37 -13.5*C38 -14.5*C39 -15.5*C40 -16.5*C41 -17.5*C42 -18.5*C43 -19.5*C44 -20.5*C45 -21.5*C46 -22.5*C47 -23.5*C48 -24.5*C49 ) / 10412.5*(24.5) + AvgC50.0

Now plot a native Moving LinReg50(Price) on the same pane - the two are coincidental.

Now plot an Exponential MovAvg(Price,10) on the pane, and apply a CHILD Moving LinReg50 to that MovAvg.

Finally, modify the Custom Indicator smoothing so that it's set for 10, Exponential. You will see that the two lines are coincidental.

So, the LR(MA) is "commutative" in that it equals the MA(LR), just as the EMA(SMA) = SMA(EMA), and so forth.

Therefore the Custom Indicator is not necessry for this ... unless you are trying to get the MovAvg of a LinReg slope or something else fancy like that.

Jim Dean


bustermu
Posted : Saturday, June 25, 2005 12:41:32 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
All "constructable" stable Linear Time Invariant (LTI) Filters commute. In addition to those mentioned above, the built-in ROC is an example.

The Ideal Integrator, implimented as a Custom Cumulative Indicator (CCI), although not stable, commutes with all "constructable" stable LTI Filters if properly interpreted.

To illustrate this, please do the following setup:

Top Window

Custom Cumulative Indicator 1
Up Condition
ABS(V)>=0.0
Down Condition
ABS(V)<0.0
Value To Add/Subtract
C-C1
Smoothing Average 10 Exponential

Custom Cumulative Indicator 2
Up Condition
ABS(V)>=0.0
Down Condition
ABS(V)<0.0
Value To Add/Subtract
XAVGC10-XAVGC10.1
Smoothing Average 1 Simple

The two CCI's will overlay one another but will not read the same values due to the way they are initialized. This demonstrates the commutivity of the Ideal Integrator and the Exponential Moving Average of period 10.

Please note that for the Ideal Integrator the CCI Up Condition is always True and the Down Condition is always False.

Thanks,
Jim Murphy
Tanstaafl
Posted : Saturday, June 25, 2005 1:45:07 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, JimM:

I understand your first sentence.

I have no clue whatsoever what the "Ideal Integrator" is ... could you please fully define it? Please note that "CCI" is a WIDELY understood name of a totally different thing (an indicator named "Commodity Channel Index" which has been dealt with extensively elsewhere). I respectfully recommend that you avoid confusion by limiting the introduction of terms that are unknown or ambiguous for the average trader/TCuser.

I *think* I understand the main point of your post to be saying two things:

1) ROC is commutative with MA's and with LinRegs, just as they are with each other (makes sense to me without much thot required)

2) Custom Cumulative (CC) implementations of any combo of #1 items are commutative with those items. That is, CC(MA) = MA(CC), or CC(LR)= LR(CC), or CC(ROC) = ROC(CC), or many other permutations of various nested levels such as: ROC(CC(LR(MA))) = MA(ROC(LR(CC))). This one took a bit more thot, but with the stated exception of the (TC-proprietary) initialization rules, it makes sense to me, too.

If #2 is not what you meant to convey, please clarify the limitations (in simple terms :~)

Thanks ... if I am understanding this correctly, it is valuable and interesting news!

Jim Dean

Tanstaafl
Posted : Saturday, June 25, 2005 1:47:15 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Aw, darn it those pesky icons hit again. Each of the 's is supposed to be ( X ) ... without the spaces!

bustermu
Posted : Sunday, June 26, 2005 10:05:18 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Jim D.,

Ideal Integrator, Euler Integrator, Integrator, and Accumulator are synonyms for the same thing in Digital Signal Processing (DSP). From the internet:

"An integrator is a single-pole IIR filter with unity feedback coefficient:

1) y(n ) = y(n-1) + x(n )

This system is also known as an accumulator. The transfer function for an integrator on the z-plane is:

2) H(z ) = 1/(1-z^(-1))"

Equivalently, the impulse response is the unit step u where:

3) u(n ) = 1, n>=0,
u(n ) = 0, n<0.

Also, the output is:

4) y(n ) = x(n )+x(n-1)+x(n-2)+...

All four of the above are equivalent definitions.

For TC2005 purposes, a Custom Cumulative Indicator (CC) is an Ideal Integrator if and only if the Up Condition is always True and the Down Condition is always False.

For example, in your notation CC(MA) = MA(CC) is not in general true, but it is true when the CC is implimented as an Ideal Integrator. So, be carful.

My point is:

1) All "constructable" stable Linear Time Invariant (LTI) filters commute.
2) CC, when implimented as an Ideal Integrator, though unstable, also commutes with all "constructable" stable LTI filters.

I used the word "constructable" to stop mathematicians from pointing out that I am wrong. Others do not usually know that I am wrong without this qualification.

Thanks,
Jim Murphy
Tanstaafl
Posted : Monday, June 27, 2005 3:39:02 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, JimM:

OK I think I get it. All the stuff about single pole filters and impulse responses is I suppose interesting to a mathematician or EE ... neither of which describes moi.

But your simple explanation that in order for CC to be part of the commutative group does make sense ... essentially you are saying that the CC has to be set up to always add the formula rather than subtract it, or skip it. Which is what you said at the bottom of your orig posting ... but my brain got fuzzed by the prelim stuff so I missed the point.

This is intuitively obvious, once pointed out ... thanks for doing so!

Jim Dean

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.