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 |

DEMA for indicators Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
sw139
Posted : Saturday, July 11, 2015 10:17:03 AM
Registered User
Joined: 9/11/2014
Posts: 14

How to create DEMA for indicators? for example williams%r, RSI, etc?

Bruce_L
Posted : Monday, July 13, 2015 4:18:59 PM


Worden Trainer

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

I'm going to start with the basic template for a 6 period double exponential moving average (DEMA) of closing prices. I'm using a period of 6 because it is long enough to demonstrate the technique but short enough that the formulas in this post don't get completely out of control.

Double Exponential Moving Average (DEMA)

2 * XAVGC6 - XAVG(XAVGC6,6)

A manual expansion of this would be quite a bit longer. The components of this manual expansion will be used for all of the rest of the expansions in this post.

Cascades of Moving Averages

.57191682 * (C + 5 / 7 * (C1 + 5 / 7 * (C2 + 5 / 7 * (C3 + 5 / 7 * (C4 + 5 / 7 * (C5 + 5 / 7 * (C6 + 5 / 7 * (C7 + 5 / 7 * (C8 + 5 / 7 * (C9 + 5 / 7 * (C10 + 5 / 7 * (C11 + 5 / 7 * (C12 + 5 / 7 * (C13 + 5 / 7 * (C14 + 5 / 7 * (C15 + 5 / 7 * (C16 + 5 / 7 * (C17 + 5 / 7 * (C18 + 5 / 7 * (C19 + 5 / 7 * (C20))))))))))))))))))))) - .023343379 * (C + 5 / 7 * (3 * C1 + 5 / 7 * (6 * C2 + 5 / 7 * (10 * C3 + 5 / 7 * (15 * C4 + 5 / 7 * (21 * C5 + 5 / 7 * (28 * C6 + 5 / 7 * (36 * C7 + 5 / 7 * (45 * C8 + 5 / 7 * (55 * C9 + 5 / 7 * (66 * C10 + 5 / 7 * (78 * C11 + 5 / 7 * (91 * C12 + 5 / 7 * (105 * C13 + 5 / 7 * (120 * C14 + 5 / 7 * (136 * C15 + 5 / 7 * (153 * C16 + 5 / 7 * (171 * C17 + 5 / 7 * (190 * C18 + 5 / 7 * (210 * C19 + 5 / 7 * (231 * C20 + 5 / 7 * (253 * C21 + 5 / 7 * (276 * C22 + 5 / 7 * (300 * C23 + 5 / 7 * (325 * C24 + 5 / 7 * (351 * C25 + 5 / 7 * (378 * C26 + 5 / 7 * (406 * C27 + 5 / 7 * (435 * C28 + 5 / 7 * (465 * C29 + 5 / 7 * (496 * C30 + 5 / 7 * (528 * C31 + 5 / 7 * (561 * C32)))))))))))))))))))))))))))))))))

Note that this only works without manually expanding at least one of the EMAs for price components and volume. This is because price components and volume have built in indicator syntax for exponential moving averages.

Exponential Moving Averages of Price and Volume

Simple moving averages are built into BOP, MS, OBV, RSI, STOC and TSV however. This would allow you to create a double simple moving averages (DSMA) or a hybrid mixing exponential and simple moving averages which would still have zero lag and be relatively short.

Let's use a 10 period Williams %R as an example. A 10 period Williams %R is just a 10 period stochastic minus 100.

STOC10 - 100

Stochastic
Williams %R

So a 6 period DSMA of a 10 period Williams %R could be written as follows.

2 * STOC10.6 - AVG(STOC10.6,6) - 100

And a hybrid where the first term is a simple moving average and the second term is an exponential moving average of that simple moving average could be written as follows.

2 * STOC10.6 - XAVG(STOC10.6,6) - 100

And a hybrid where the first term is an exponential moving average the second term is a simple moving of that exponential moving averages could be written as follows.

2 * XAVG(STOC10,6) - XAVG(STOC10.6,6) - 100

To actually get a real DEMA where both the first and second terms only use exponential moving averages requires at least one manual expansion however. The easiest to do is probably just manually expand a single EMA for the second term.

2 * XAVG(STOC10,6) - .28595841 * (XAVG(STOC10.1.,6) + 5 / 7 * (XAVG(STOC10.1.1,6) + 5 / 7 * (XAVG(STOC10.1.2,6) + 5 / 7 * (XAVG(STOC10.1.3,6) + 5 / 7 * (XAVG(STOC10.1.4,6) + 5 / 7 * (XAVG(STOC10.1.5,6) + 5 / 7 * (XAVG(STOC10.1.6,6) + 5 / 7 * (XAVG(STOC10.1.7,6) + 5 / 7 * (XAVG(STOC10.1.8,6) + 5 / 7 * (XAVG(STOC10.1.9,6) + 5 / 7 * (XAVG(STOC10.1.10,6) + 5 / 7 * (XAVG(STOC10.1.11,6) + 5 / 7 * (XAVG(STOC10.1.12,6) + 5 / 7 * (XAVG(STOC10.1.13,6) + 5 / 7 * (XAVG(STOC10.1.14,6) + 5 / 7 * (XAVG(STOC10.1.15,6) + 5 / 7 * (XAVG(STOC10.1.16,6) + 5 / 7 * (XAVG(STOC10.1.17,6) + 5 / 7 * (XAVG(STOC10.1.18,6) + 5 / 7 * (XAVG(STOC10.1.19,6) + 5 / 7 * (XAVG(STOC10.1.20,6)))))))))))))))))))))) - 100

But if you are going to do a manual expansion anyway, you are probably better off eliminating the XAVG() functions from the second main term even if that manual expansion requires more terms itself and is a bit longer.

2 * XAVG(STOC10,6) - .023343379 * (STOC10 + 5 / 7 * (3 * STOC10.1.1 + 5 / 7 * (6 * STOC10.1.2 + 5 / 7 * (10 * STOC10.1.3 + 5 / 7 * (15 * STOC10.1.4 + 5 / 7 * (21 * STOC10.1.5 + 5 / 7 * (28 * STOC10.1.6 + 5 / 7 * (36 * STOC10.1.7 + 5 / 7 * (45 * STOC10.1.8 + 5 / 7 * (55 * STOC10.1.9 + 5 / 7 * (66 * STOC10.1.10 + 5 / 7 * (78 * STOC10.1.11 + 5 / 7 * (91 * STOC10.1.12 + 5 / 7 * (105 * STOC10.1.13 + 5 / 7 * (120 * STOC10.1.14 + 5 / 7 * (136 * STOC10.1.15 + 5 / 7 * (153 * STOC10.1.16 + 5 / 7 * (171 * STOC10.1.17 + 5 / 7 * (190 * STOC10.1.18 + 5 / 7 * (210 * STOC10.1.19 + 5 / 7 * (231 * STOC10.1.20 + 5 / 7 * (253 * STOC10.1.21 + 5 / 7 * (276 * STOC10.1.22 + 5 / 7 * (300 * STOC10.1.23 + 5 / 7 * (325 * STOC10.1.24 + 5 / 7 * (351 * STOC10.1.25 + 5 / 7 * (378 * STOC10.1.26 + 5 / 7 * (406 * STOC10.1.27 + 5 / 7 * (435 * STOC10.1.28 + 5 / 7 * (465 * STOC10.1.29 + 5 / 7 * (496 * STOC10.1.30 + 5 / 7 * (528 * STOC10.1.31 + 5 / 7 * (561 * STOC10.1.32))))))))))))))))))))))))))))))))) - 100

You could directly replace the syntax for stochastic indicator with the syntax for the relative strength index indicator in the formulas above as long as the RSI is the plain RSI built into the Personal Criteria Formula Language without Wilder's smoothing. Any Indicator Formula for the DEMA of a Wilder's smoothed RSI would be too long and slow to be practical however.

In fact, this last bit of syntax can be used with any indicator actually built into the Personal Criteria Formula Language. You just need to substitute the syntax for that indicator for the syntax of the stochastic.

Anything not built into the Personal Criteria Formula Language as an indicator is going to have to go all the way back to the second formula presented in the topic to get a template however. You would need to replace C in this formula with the appropriate bars ago version of the syntax for for the desired indicator. You may also have to place that syntax insider parentheses in order to force the correct calculation order.

Let's say you have something as simple as a 1-period price percent change.

100 * (C / C1 - 1)

Re-arranging this a bit would allow us to the contruct the following Indicator Formula for a 6 period DEMA.

57.191682 * (C / C1 + 5 / 7 * (C1 / C2 + 5 / 7 * (C2 / C3 + 5 / 7 * (C3 / C4 + 5 / 7 * (C4 / C5 + 5 / 7 * (C5 / C6 + 5 / 7 * (C6 / C7 + 5 / 7 * (C7 / C8 + 5 / 7 * (C8 / C9 + 5 / 7 * (C9 / C10 + 5 / 7 * (C10 / C11 + 5 / 7 * (C11 / C12 + 5 / 7 * (C12 / C13 + 5 / 7 * (C13 / C14 + 5 / 7 * (C14 / C15 + 5 / 7 * (C15 / C16 + 5 / 7 * (C16 / C17 + 5 / 7 * (C17 / C18 + 5 / 7 * (C18 / C19 + 5 / 7 * (C19 / C20 + 5 / 7 * (C20 / 21))))))))))))))))))))) - 2.3343379 * (C / C1 + 5 / 7 * (3 * C1 / C2 + 5 / 7 * (6 * C2 / C3 + 5 / 7 * (10 * C3 / C4 + 5 / 7 * (15 * C4 / C5 + 5 / 7 * (21 * C5 / C6 + 5 / 7 * (28 * C6 / C7 + 5 / 7 * (36 * C7 / C8 + 5 / 7 * (45 * C8 / C9 + 5 / 7 * (55 * C9 / C10 + 5 / 7 * (66 * C10 / C11 + 5 / 7 * (78 * C11 / C12 + 5 / 7 * (91 * C12 / C13 + 5 / 7 * (105 * C13 / C14 + 5 / 7 * (120 * C14 / C15 + 5 / 7 * (136 * C15 / C16 + 5 / 7 * (153 * C16 / C17 + 5 / 7 * (171 * C17 / C18 + 5 / 7 * (190 * C18 / C19 + 5 / 7 * (210 * C19 / C20 + 5 / 7 * (231 * C20 / C21 + 5 / 7 * (253 * C21 / C22 + 5 / 7 * (276 * C22 / C23 + 5 / 7 * (300 * C23 / C24 + 5 / 7 * (325 * C24 / C25 + 5 / 7 * (351 * C25 / C26 + 5 / 7 * (378 * C26 / C27 + 5 / 7 * (406 * C27 / C28 + 5 / 7 * (435 * C28 / C29 + 5 / 7 * (465 * C29 / C30 + 5 / 7 * (496 * C30 / C31 + 5 / 7 * (528 * C31 / C32 + 5 / 7 * (561 * C32 / C33))))))))))))))))))))))))))))))))) - 100



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
sw139
Posted : Tuesday, July 14, 2015 11:16:39 AM
Registered User
Joined: 9/11/2014
Posts: 14

thanks!

Bruce_L
Posted : Tuesday, July 14, 2015 11:24:22 AM


Worden Trainer

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

You're welcome.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
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.