OPEN-SOURCE SCRIPT
Better DEMA

The Better DEMA is a new tool designed to recreate the classical moving average DEMA, into a smoother, more reliable tool. Combining many methodologies, this script offers users a unique insight into market behavior.
How does it work?
First, to get a smoother signal, we need to calculate the Gaussian filter. A Gaussian filter is a smoothing filter that reduces noise and detail by averaging data with weights following a Gaussian (bell-shaped) curve.
Now that we have the source, we will calculate the following:
n2 = n/2 (half of the user defined length)
a = 2/(1+n)
ns
Now that we have that out of the way, it is time to get into the core.
Now we calculate 2 EMAs:
slow EMA => EMA over n
fast EMA => EMA over n2 period
Rather then now doing this:
DEMA = fast EMA * 2 - slow EMA
I found this to be better:
DEMA = slow EMA * (1-a) + fast EMA * a
As a last touch I took a little something from the HMA, and used a EMA with period of √n to smooth the entire the thing.
The Trend condition at base is the following (but feel free to FAFO with it):
Long = dema > dema yesterday and dema < src
Short = dema < dema yesterday and dema > src
Methodology
While the DEMA is an amazing tool used in many great indicators, it can be far too noisy.
This made me test out many filters, out of which the Gaussian performed best.
Then I tried out the non subtractive approach and that worked too, as it made it smoother.
Compacting on all I learned and smoothing it bit by bit, I think I can say this is worth looking into :).
Use cases:
Following Trends => classic, effective :)
Smoothing sources for other indicators => if done well enough, could be useful :)
Easy trend visualization => Added extra options for that.
Strategy development => Yes
Another good thing is it does not a high lookback period, so it should be better and less overfit.
That is all for today Gs,
Have fun and enjoy!
How does it work?
First, to get a smoother signal, we need to calculate the Gaussian filter. A Gaussian filter is a smoothing filter that reduces noise and detail by averaging data with weights following a Gaussian (bell-shaped) curve.
Now that we have the source, we will calculate the following:
n2 = n/2 (half of the user defined length)
a = 2/(1+n)
ns
Now that we have that out of the way, it is time to get into the core.
Now we calculate 2 EMAs:
slow EMA => EMA over n
fast EMA => EMA over n2 period
Rather then now doing this:
DEMA = fast EMA * 2 - slow EMA
I found this to be better:
DEMA = slow EMA * (1-a) + fast EMA * a
As a last touch I took a little something from the HMA, and used a EMA with period of √n to smooth the entire the thing.
The Trend condition at base is the following (but feel free to FAFO with it):
Long = dema > dema yesterday and dema < src
Short = dema < dema yesterday and dema > src
Methodology
While the DEMA is an amazing tool used in many great indicators, it can be far too noisy.
This made me test out many filters, out of which the Gaussian performed best.
Then I tried out the non subtractive approach and that worked too, as it made it smoother.
Compacting on all I learned and smoothing it bit by bit, I think I can say this is worth looking into :).
Use cases:
Following Trends => classic, effective :)
Smoothing sources for other indicators => if done well enough, could be useful :)
Easy trend visualization => Added extra options for that.
Strategy development => Yes
Another good thing is it does not a high lookback period, so it should be better and less overfit.
That is all for today Gs,
Have fun and enjoy!
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.