Schaff Trend with CCI

Forums ProRealTime English forum ProBuilder support Schaff Trend with CCI

  • This topic has 2 replies, 2 voices, and was last updated 6 years ago by avatarLoop.

Tagged: ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • #87131

    Indicator found in Tradingview website:

    https://www.tradingview.com/script/SYXp2cAq-CCI-Cycle-Modified-Schaff-Trend-Cycle/

    Code:

    //@version=3

    study(title=”CCI Cycle”, shorttitle=”CCI Cycle”, overlay=false)

    // ——————————- Inputs ——————————- //
    src = input(close, title=”Source”)
    length=input(10)
    useCurrentRes = input(true, title=”Use Current Chart Resolution?”)
    resCustom = input(“240″, title=”Use Different Timeframe? Uncheck Box Above”)

    res = useCurrentRes ? period : resCustom

    // ——————————- CCI ——————————- //
    ma = sma(src, length)
    cci = (src – ma) / (0.015 * dev(src, length))
    ccis = security(tickerid, res, rma(2*ema(cci, length/2)-ema(cci, length), round(sqrt(length))))

    // ——————————- Cycle ——————————- //
    ccic(length) =>
    factor=input(0.5)
    m = ccis
    v1 = lowest(m, length)
    v2 = highest(m, length) – v1
    f1 = 0.0
    f1 := (v2 > 0 ? ((m – v1) / v2) * 100 : nz(f1[1]))
    pf = 0.0
    pf := (na(pf[1]) ? f1 : pf[1] + (factor * (f1 – pf[1])))
    v3 = lowest(pf, length)
    v4 = highest(pf, length) – v3
    f2 = 0.0
    f2 := (v4 > 0 ? ((pf – v3) / v4) * 100 : nz(f2[1]))
    pff = 0.0
    pff := (na(pff[1]) ? f2 : pff[1] + (factor * (f2 – pff[1])))
    pff

    CCIC = security(tickerid, res, ccic(length))

    // ——————————- Plotting ——————————- //

    plot(CCIC,color=red, title=”CCI Cycle”)
    ul=plot(25)
    ll=plot(75)
    fill(ul,ll,color=red)

     

    It should be very similar to Schaff indicator but with earlier signals.

    If you go at the abocìve reported web link you can also find how it look like!

     

    Thanks a lot in advance

    #87283

    I changed the code found here: Schaff Trend Cycle

    to made the calculation with a CCI instead of a MACD, here it is:

     

    Please next time use the correct form and rules, to ask for a code conversion: Ask for a free code conversion

    1 user thanked author for this post.
    #87413

    Thanks Nicolas for your valuable help!

Viewing 3 posts - 1 through 3 (of 3 total)

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