Conversion of John F. Ehlers – Decycler (available on tradingview)

Forums ProRealTime English forum ProBuilder support Conversion of John F. Ehlers – Decycler (available on tradingview)

Viewing 2 posts - 1 through 2 (of 2 total)
  • #119775

    In an interview (http://bettersystemtrader.com/048-john-ehlers/) with John Ehlers, I heard him being asked what his favorite indicators are.

    His top indicator is the decycler. I didn’t find anything about it on PRT, but the code can be found on Tradingview. Maybe a good addition Prorealcode?

    https://de.tradingview.com/script/ZuIZPR4q-Ehlers-Simple-Decycler/
    https://de.tradingview.com/script/5xelSGhd-Ehlers-Decycler-Oscillator/

    //@version=3
    // Copyright (c) 2019-present, Alex Orekhov (everget)
    // Ehlers Simple Decycler script may be freely distributed under the MIT license.
    study(“Ehlers Simple Decycler”, shorttitle=”Decycler”, overlay=true)

    highpassLength = input(title=”Highpass Period”, type=integer, defval=125)
    upperPercent = input(title=”Upper Band % Shift”, type=float, minval=0, step=0.1, defval=0.5)
    lowerPercent = input(title=”Lower Band % Shift”, type=float, minval=0, step=0.1, defval=0.5)
    src = input(title=”Source”, type=source, defval=close)
    highlightMovements = input(title=”Highlight Decycler Movements ?”, type=bool, defval=true)

    PI = 2 * asin(1)

    // High-pass Filter
    alphaArg = 2 * PI / (highpassLength * sqrt(2))

    alpha = 0.0
    alpha := cos(alphaArg) != 0
    ? (cos(alphaArg) + sin(alphaArg) – 1) / cos(alphaArg)
    : nz(alpha[1])

    hp = 0.0
    hp := pow(1 – (alpha / 2), 2) * (src – 2 * nz(src[1]) + nz(src[2])) + 2 * (1 – alpha) * nz(hp[1]) – pow(1 – alpha, 2) * nz(hp[2])

    decycler = src – hp

    decyclerColor = highlightMovements ? (decycler >= decycler[1] ? green : red) : #741b47
    plot(decycler, title=”Decycler”, linewidth=2, color=decyclerColor, transp=0)

    upperBand = (1 + upperPercent / 100) * decycler
    lowerBand = (1 – lowerPercent / 100) * decycler

    bandColor = #138484
    upperBandPlot = plot(upperBand, title=”Upper”, color=bandColor)
    lowerBandPlot = plot(lowerBand, title=”Lower”, color=bandColor)
    fill(upperBandPlot, lowerBandPlot, title=”Background”, color=color(#ffd966, 84))

    //@version=3
    // Copyright (c) 2019-present, Alex Orekhov (everget)
    // Ehlers Decycler Oscillator script may be freely distributed under the MIT license.
    study(“Ehlers Decycler Oscillator”, shorttitle=”Decycler Oscillator”)

    hpPeriod = input(title=”High-pass Filter Period”, type=integer, defval=125)
    k = input(title=”K Multiplier”, type=float, step=0.1, defval=1)
    hpPeriod2 = input(title=”High-pass Filter Period 2″, type=integer, defval=100)
    k2 = input(title=”K Multiplier 2″, type=float, step=0.1, defval=1.2)
    src = input(title=”Source”, type=source, defval=close)
    highlightCrossovers = input(title=”Highlight Crossovers ?”, type=bool, defval=true)
    highlightZeroCrossovers = input(title=”Highlight Zero Line Crossovers ?”, type=bool, defval=false)
    applyFilling = input(title=”Apply Ribbon Filling ?”, type=bool, defval=false)

    PI = 2 * asin(1)

    // High-pass Filter
    _hp(src, hpPeriod, mult) =>
    alphaArg = 2 * PI / (mult * hpPeriod * sqrt(2))

    alpha = 0.0
    alpha := cos(alphaArg) != 0
    ? (cos(alphaArg) + sin(alphaArg) – 1) / cos(alphaArg)
    : nz(alpha[1])

    hp = 0.0
    hp := pow(1 – (alpha / 2), 2) * (src – 2 * nz(src[1]) + nz(src[2])) + 2 * (1 – alpha) * nz(hp[1]) – pow(1 – alpha, 2) * nz(hp[2])
    hp

    hp = _hp(src, hpPeriod, 1)
    decycler = src – hp
    decosc = 100 * k * _hp(decycler, hpPeriod, 0.5) / src

    hp2 = _hp(src, hpPeriod2, 1)
    decycler2 = src – hp2
    decosc2 = 100 * k2 * _hp(decycler2, hpPeriod2, 0.5) / src

    trendColor = decosc2 > decosc ? #0ebb23 : red

    decoscColor = applyFilling ? trendColor : #ff5048
    decosc2Color = applyFilling ? trendColor : #f5c75e

    decoscPlot = plot(decosc, title=”1″, linewidth=2, color=decoscColor, transp=0)
    decosc2Plot = plot(decosc2, title=”2″, linewidth=2, color=decosc2Color, transp=0)
    hline(0, title=”Zero Level”, linestyle=dotted)

    transparent = color(white, 100)

    fillColor = applyFilling ? trendColor : transparent
    fill(decoscPlot, decosc2Plot, color=fillColor, transp=70)

    zeroCrossBgColor = highlightZeroCrossovers ? (decosc > 0 or decosc2 > 0 ? green : red) : transparent
    bgcolor(zeroCrossBgColor, transp=85)

    plotshape(highlightCrossovers and crossover(decosc, decosc2) ? avg(decosc, decosc[1]) : na, title=”Crossover”, location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0)
    plotshape(highlightCrossovers and crossunder(decosc, decosc2) ? avg(decosc, decosc[1]) : na, title=”Crossunder”, location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0)

    #125167

    Sorry for late reply, the Ehlers Simple Decycler is downloadable from here: Ehlers Simple Decycler

    1 user thanked author for this post.
Viewing 2 posts - 1 through 2 (of 2 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login