Hull Moving Average using DEMA
Author: kvmp
Creation Date: 9/21/2010 11:08 AM
profile picture

kvmp

#1
Can you please help me to create Hull Moving Average using DEMA instead of WMA.

Thank you
profile picture

Eugene

#2
Do you already have the complete formula for your creature? Not the DEMA (it's obvious) - I'm rather asking for the algorithm because your request goes beyond simply plugging in another type of average in the HullMA formula.

See the difference?

DEMA:
CODE:
Please log in to see this code.


HullMA:
CODE:
Please log in to see this code.
profile picture

kvmp

#3
Thank you Eugene for helping me. Here is what I had planed to do. I have very little knowledge of writing WL Scripts. I only copy and paste:
CODE:
Please log in to see this code.

Up to line," DataSeries DEMA = ( S1 + ( S1 - S2 )) ;" I did not get any error message. Next three lines created error messages. I think there is much more to what I have written in the Script, and I don't know/understand that. Please help.
profile picture

Eugene

#4
Please always use the CODE button whenever posting code, thank you. Below "Add new Post" there's a line with buttons Bold, Italic, CODE etc. Click "CODE" and paste your code in between the tags.

QUOTE:
Up to line," DataSeries DEMA = ( S1 + ( S1 - S2 )) ;" I did not get any error message.

That's because to refer to DEMA the way you're doing, first it has to be "formalized" i.e. the Series method has to be implemented.
CODE:
Please log in to see this code.

No no, this doesn't make any sense - not the code, but the logic. DEMA has two mandatory periods, you can't just arbitrarily define a DEMA(13) or DEMA(26) - you provide no explanation how would you do this!

As you might understand, ( D1 + ( D1 - D2 )) is always equal to D1 because D1 == D2.

In other words, your code is trying to turn a 2-parameter DEMA into a single-parameter: magically, without telling how exactly... which requires modification to DEMA formula... so it's no longer a DEMA but a different MA :)

Given that the logic/formula is not clear, to fix your code I have 2 suggestions:

1) Take some other applicable MA instead of DEMA - like SMA, EMA, SMMA, T3MA etc.
2) Use 2 sets of DEMA - one with the parameters 13,26, another with some different parameters. This is a valid use of DEMA.
profile picture

Eugene

#5
Just in case somebody stumbles onto this thread, the DEMA moving average has been added to Community Indicators v2019.02.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).