Double Exponential Moving Average

Optuma Forums Optuma Scripting Double Exponential Moving Average

Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #58299
    AvatarTonia
    • Topics: 6
    • Replies: 6
    • Posts: 12

    Hi Optuma

    Topic Title (Maximum Length: 80):

    VisualText

    Hi Optuma

    I’ve looked through tools and can’t find anything that resembles the Double Exponential Moving Average I am looking for, so I am hoping you can help write a script for me to use in my analysis.

    To calculate the DEMA I think you need to:- identify the look-back period and the EMA(n). I would like the look-back period to be 15 days, and calculate the EMA for that period, which becomes the EMA(n). Then I need to apply an EMA with the same look-back period as the EMA(n), which again will be 5, which I am hoping will give a smoothed EMA. The script then needs to multiply the EMA(n) by 2 and subtract the smoothed EMA.

    How to Calculate the Double Exponential Moving Average (DEMA)
    Choose any lookback period, such as five periods, 15 periods, or 100 periods.
    Calculate the EMA for that period, this is EMA(n).
    Apply an EMA with the same lookback period to EMA(n). This gives a smoothed EMA.
    Multiply two times the EMA(n) and subtract the smoothed EMA

    So basically the formula for the Double Exponential Moving Average (DEMA) should reflect this:
    DEMA=2 x times EMA(n) – EMA of EMA(n) where n=Look-back period.

    Hoping you can help me.

    Thanks guys.

    Tonia

     

     

    #58317
    DarrenDarren
    • Topics: 53
    • Replies: 428
    • Posts: 481

    Hi Tonia,

    You start by calculating the EMA and then nest that in the 2nd EMA. Use this formula in a Show Plot (to adjust the lookback period change the #$LB variable from 15).

    Save the script as an indicator to the same view, and it will then be available in your toolbox. Once applied you can change the colour etc in the properties and save as default or add a custom button to your toolbar:Capture

    For Triple (TEMA) and Quadruple (QEMA) exponentials see here: https://forum.optuma.com/topic/tema-from-stocks-commodities-feb-1994/

    • This reply was modified 1 month, 2 weeks ago by DarrenDarren.
    #58325
    AvatarTonia
    • Topics: 6
    • Replies: 6
    • Posts: 12

    Hi Darren, so grateful for this, thank you. If I wanted to adjust the script above to show a dema crossover, ie 10 dema crosses 30 dema, do I have to name each dema first and then use the crossover function ie DEMA1 CrossesAbove DEMA2. Optuma doesn’t recognise DEMA like it does MA I don’t think. What names can I give to DEMA that Optuma scripting will recognise here. Thank you.

    #58327
    DarrenDarren
    • Topics: 53
    • Replies: 428
    • Posts: 481

    Ah in that case you will need to create both DEMAs using the different lookback periods. This will draw both using the Show Plot tool:

    To change it to a true/false boolean condition for a crossover in a Show Bar or Scan delete from Line 11 and replace with DEMA1 CrossesAbove DEMA2.

    • This reply was modified 1 month, 2 weeks ago by DarrenDarren.
    #58333
    AvatarTonia
    • Topics: 6
    • Replies: 6
    • Posts: 12

    Thank you Darren, that’s exactly what I wanted. I would not have worked out the second part of the calculation you have written, nor the boolean conditions. You’ve been a great help to me.

    Regards

    Tonia

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close