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 |

MACD histogram and moving averages of custom indicators Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
krck
Posted : Sunday, March 26, 2006 11:04:56 AM
Registered User
Joined: 2/27/2006
Posts: 16
I would appreciate some further explanations regarding moving averages in PCFs.

I viewed the Understanding MACD videos Understanding MACD
and I gather that the MACD histogram is
MACD - 'exponential moving average of MACD for signal periods' =
MACD(long,short) - EMA( MACD(long,short), signal )

which in PCF language translates to
( XAVGCshort - XAVGClong ) - ( XAVG(XAVGCsignal,short) - XAVG(XAVGClong,signal) )

This formula seems to be more or less consistent with the MACD plotted by the software.

For the sake of understanding, so that I may successfully create my own PCF's without bothering
the trainers too much, I would appreciate the explanation of the following:

I would appreciate the mathematical explanation of

1. Why does the formula ( XAVG(XAVGCsignal,short) - XAVG(XAVGClong,signal) ) represent the
exponential moving average of MACD?

2. Would the similar formula for a simple moving average of MACD be
AVG(AVGCsignal,short) - AVG(AVGClong,signal)
or
AVG(AVGCshort,signal) - AVG(AVGClong,signal)?

3. If I had a custom indicator with several terms such as
term1 + term2 + ... + termN
what would be its moving average and exponential moving average?
Could I approximate those moving averages by say reducing the terms to two terms
termA + termB and then using the above formulas?

Thanks.
Bruce_L
Posted : Monday, March 27, 2006 7:36:35 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (krck)
Why does the formula ( XAVG(XAVGCsignal,short) - XAVG(XAVGClong,signal) ) represent the exponential moving average of MACD?

Moving Averages are distributive over substraction so XAVG(XAVGCshort,signal) - XAVG(XAVGClong,signal) is the same as XAVG(XAVGCshort - XAVGClong,signal), but formulas cannot be used inside an XAVG() function so the first form must be used in TeleChart's Personal Criteria Formula Language. Nested Moving Averages are also commutative, so XAVG(XAVGCsignal,short) is the same as XAVG(XAVGCshort,signal).

QUOTE (krck)
Would the similar formula for a simple moving average of MACD be AVG(AVGCsignal,short) - AVG(AVGClong,signal) or AVG(AVGCshort,signal) - AVG(AVGClong,signal)?

For the reasons above, either should work fine.

QUOTE (krck)
If I had a custom indicator with several terms such as term1 + term2 + ... + termN what would be its moving average and exponential moving average?

Moving Averages are also distributive over addition so, AVG(term1,x) + AVG(term2,x) + ... + AVG(termN,x) or XAVG(term1,x) + XAVG(term2,x) + ... + XAVG(termN,x) as appropriate.

QUOTE (krck)
Could I approximate those moving averages by say reducing the terms to two terms termA + termB and then using the above formulas?

I'm not sure I understand the question, but suspect it would depend on the exact formula.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
krck
Posted : Monday, March 27, 2006 1:59:27 PM
Registered User
Joined: 2/27/2006
Posts: 16
Thanks for clearing that up.

There is one more practical issue.

When I plot MACD as a custom formula
XAVGC10 - XAVGC21
and then add exponential moving average to it with the period of 5,

then plot two more custom indicators that ought to represent the
same exponential moving average,
a) XAVG(XAVGC10,5) - XAVG(XAVGC21,5) center zero line
and
b) XAVG(XAVGC5,10) - XAVG(XAVGC21,5) center zero line

a) and b) are identical, however they both differ from the original moving average.

The shape is similar, but there are offsets between them.

Which one is the correct one?
Should I scale/offset the formula to get a more accurate version?
If so, how?

Thanks.
Bruce_L
Posted : Monday, March 27, 2006 2:05:25 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
They produce the same values but are scaled differently. The 5-Period Exponential Moving Average of the Custom Indicator is being plotted on the same scale as the Custom Indicator while the formulas that already include the 5-Period EMA are plotting on their own scales (if you changed the Smoothing Average to 5 on the XAVGC10 - XAVGC21 and selected Exponential it would line up with the formulas that already include the 5-Period EMA).

If you are interested in visualizing the crossing, either just use the built in MACD indicator or add a 5-Period Exponential Moving Average as a Child Indicator of the MACD Custom Indicator.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
krck
Posted : Tuesday, March 28, 2006 7:21:02 AM
Registered User
Joined: 2/27/2006
Posts: 16
I added the 5 period EMA as a child of custom MACD previously.
The same only lined up to the custom EMA formulas when the custom formulas were further smoothed by 5 exponentially.

I did not exactly understand the scaling issues.
Is the following correct?

1. The 'XAVG(XAVGC10,5)-XAVG(XAVGC21,5)' formula produces the actual accurate raw exponential moving average of the MACD indicator. Plotted without smoothing it is exactly as its underlying values.
2. The 5 period EMA child of custom MACD or any custom indicator is by default plotted as a smoothed version of itself, the smoothing factor being the EMA period.

I wanted my scan PCFs to be accurate and to match the visual indicators.

Bruce_L
Posted : Tuesday, March 28, 2006 7:45:56 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (krck)
I did not exactly understand the scaling issues.

A Custom Indicator is plotted in one of three ways.

1. It can be plotted on the Price Scale. In this mode, the range of the chart is set by the default range in the top section of the chart.

2. It can be plotted with a Centered Zero Line. In this mode, the displayed value furthest from zero is used as the both the top and bottom values of the scale.

3. It can be plotted without either checked. In this mode, the highest displayed value is used as the top of the scale and the lowest displayed value is used as the bottom of the scale.

This means that if you are using 1, Custom Indicators are plotted on their own scale, but the results must fall within the range of the displayed price to show on the charts. If you are using 2 or 3, each Custom Indicator is displayed on its own scale based entirely on its own minimum and maximum values during the period displayed.

QUOTE (krck)
I added the 5 period EMA as a child of custom MACD previously. The same only lined up to the custom EMA formulas when the custom formulas were further smoothed by 5 exponentially.

What I was trying to say was that:

Select Chart Template | Add Indicator | Indicator.
-Center Zero Line: Checked
-Plot using price scale: Unchecked
-Smoothing Average: 5
-Average Type: Exponential
-Indicator Formula: XAVGC10 - XAVGC21

Should line up exactly with:

Select Chart Template | Add Indicator | Indicator.
-Center Zero Line: Checked
-Plot using price scale: Unchecked
-Smoothing Average: 1
-Indicator Formula: XAVG(XAVGC10,5) - XAVG(XAVGC21,5)

QUOTE (krck)
The 'XAVG(XAVGC10,5)-XAVG(XAVGC21,5)' formula produces the actual accurate raw exponential moving average of the MACD indicator. Plotted without smoothing it is exactly as its underlying values.

If I'm understanding the statement correctly, this would seem to be correct.

QUOTE (krck)
The 5 period EMA child of custom MACD or any custom indicator is by default plotted as a smoothed version of itself, the smoothing factor being the EMA period.

I don't think I understand this statement well enough to say yes or no, but:

Select Chart Template | Add Indicator | Indicator.
-Center Zero Line: Checked
-Plot using price scale: Unchecked
-Smoothing Average: 5
-Average Type: Exponential
-Indicator Formula: XAVGC10 - XAVGC21

Has the same values as the Moving Average in the following:

Select Chart Template | Add Indicator | Indicator.
-Center Zero Line: Checked
-Plot using price scale: Unchecked
-Smoothing Average: 1
-Indicator Formula: XAVGC10 - XAVGC21
Select Chart Template | Add Indicator | Moving Average | FormulaXAVGC10 - XAVGC21 1 Period
-Period: 5
-Average Type: Exponential
-Shift Left: Unchecked

But they will not line up because the first is plotted on its own scale while the second is a Child Indicator plotted on the scale of the second Custom Indicator.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
krck
Posted : Wednesday, April 5, 2006 8:04:09 AM
Registered User
Joined: 2/27/2006
Posts: 16
I noticed that there is a grey button on the right at the bottom of the middle and bottom indicator windows. When pressed it displays the scale of the next indicator.

I don't suppose there is currently a way of aligning different indicators to one and the same scale in the same indicator window?
Craig_S
Posted : Wednesday, April 5, 2006 8:34:58 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
There is not a practical way of doing this, no.

- Craig
Here to Help!
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.