Request: Ehlers Deycler (from TradingView)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #234906 quote
    Trianenn
    Participant
    New

    Hello,

    I’m trying to convert this Ehlers Deycler indicator from TradingView but I can’t seem to get it work.

    Here is my code:

    // Input parameters
    length = 60
    src = close
    
    // Constants
    once PI = 3.141592653589793
    
    // Variables
    PIx2Length = 2 * PI / length
    cosValue = cos(PIx2Length)
    
    alpha = 0
    If (cosValue <> 0) then
       alpha = (cosValue + sin(PIx2Length) - 1) / cosValue
    else
       If (barindex > 1) then
          alpha = alpha[1]
       endif
    endif
    
    decycler = alpha / 2 * (src + src[1]) + (1 - alpha) * decycler[1]
    
    // Plotting the Decycler
    return decycler AS "Decycler"

    I would appreciate if someone could point me to my mistake(s).

    #234908 quote
    JS
    Participant
    Senior
    #234909 quote
    Trianenn
    Participant
    New

    Thanks JS!

    Although the indicators share the same name, the calculation is not the exactly the same.

    #234910 quote
    JS
    Participant
    Senior

    True, but all the Decyclers I’ve seen have a different calculation… 🙂

    It’s such a difficult subject that I can’t judge which calculation is the right one…

    #234931 quote
    Iván González
    Moderator
    Master
    You only have to convert radians to degrees.
    PIx2Length=2*PI/length
    transf = PIx2Length*360/(2*PI)
    cosine=COS(transf)
    PRT works with degrees and TV works with radians. Here you have the code:
    //-----Inputs------------------------------------//
    length=60
    src=close
    colorMA=1
    //-----------------------------------------------//
    //-----Moving average calculation----------------//
    once PI = 3.14159265359
    
    if barindex > length then
    
    PIx2Length=2*PI/length
    transf = PIx2Length*360/(2*PI)
    
    cosine=COS(transf)
    alpha=0
    
    if cosine<>0 then
    alpha=(cosine+sin(transf)-1)/cosine
    else
    alpha=alpha[1]
    endif
    
    MA=0
    MA=alpha/2*(src+src[1])+(1-alpha)*MA[1]
    //-----------------------------------------------//
    //-----Color MA configuration--------------------//
    if colorMA then
    if MA>MA[1] then
    r=0
    g=255
    elsif MA<MA[1] then
    r=255
    g=0
    endif
    endif
    endif
    
    return MA as "Decycler" coloured(r,g,0)style(line,2)
    Trianenn and JS thanked this post
    #234938 quote
    Trianenn
    Participant
    New
    Perfect! Thanks Iván
    JS thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Request: Ehlers Deycler (from TradingView)


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Trianenn @trianenn Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by Trianenn
1 year, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/07/2024
Status: Active
Attachments: No files
Logo Logo
Loading...