Request: (Hurst) Cycle Channel Oscillator (LazyBear, Tradingview)

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #120980 quote
    caoticoPRC
    Participant
    Junior

    Hi!

    I’ve been using prorealtime and using work done in ProRealCode Phorum for a while, and I am really grateful for the job. This is my first message and request. I’va fallen in love with an adaptation made in Tradingview of this indicator, https://www.prorealcode.com/prorealtime-indicators/hurst-cycle-channel-clone/. 

    The same author has created the indicator transformed in an Oscillator (Link here). The thing is that there is an option to apply the code, instead of the price, to another mean or indicator, and I think is a really interesting and useful transformation (transform an average in an oscillator, can smooth and supress noise and pullbacks, etc). Could it be translated to PRT having that option of applying to another indicator or average?  Thanks in advance!

    (It has also the option of painting candlebars, Maybe is interesting, but for me it wouldn’t be necessary in case means extra work for you).

    I attach here the original pinescript code:

    //
    // @author LazyBear
    //
    study("Hurst Cycle Channel Clone Oscillator [LazyBear]", shorttitle="HCCCO_LB", overlay=false)
    scl_t = input(10, title="Short Cycle Length?")
    mcl_t = input(30, title="Medium Cycle Length?")
    scm = input(1.0, title="Short Cycle Multiplier?")
    mcm = input(3.0, title="Medium Cycle Multiplier?")
    src=input(close, title="Source")
    scl = scl_t/2, mcl = mcl_t/2
    ma_scl=rma(src,scl)
    ma_mcl=rma(src,mcl)
    scm_off = scm*atr(scl)
    mcm_off = mcm*atr(mcl)
    scl_2=scl/2, mcl_2=mcl/2
    sct = nz(ma_scl[scl_2], src)+ scm_off
    scb = nz(ma_scl[scl_2], src)- scm_off
    mct = nz(ma_mcl[mcl_2], src)+ mcm_off
    mcb = nz(ma_mcl[mcl_2], src)- mcm_off
    scmm=avg(sct,scb)
    ul=plot(1.0, title="UpperLine", color=gray), ml=plot(0.5, title="MidLine", color=gray), ll=plot(0.0, title="LowerLine", color=gray)
    fill(ll,ml,color=red), fill(ul,ml,color=green)
    omed=(scmm-mcb)/(mct-mcb)
    oshort=(src-mcb)/(mct-mcb)
    plot(omed>=1.0?omed:na, histbase=1.0, style=histogram, color=purple, linewidth=2, title="MediumCycleOB")
    plot(omed<=0.0?omed:na, histbase=0.0, style=histogram, color=purple, linewidth=2, title="MediumCycleOS")
    plot(oshort>=1.0?oshort:na, histbase=1.0, style=histogram, color=purple, linewidth=2, title="ShortCycleOB")
    plot(oshort<=0.0?oshort:na, histbase=0.0, style=histogram, color=purple, linewidth=2, title="ShortCycleOS")
    plot(oshort, color=red, linewidth=2, title="FastOsc")
    plot(omed, color=green, linewidth=2, title="SlowOsc")
    ebc=input(false, title="Enable bar colors")
    bc=(oshort>0.5)?(oshort>1.0?purple:(oshort>omed?lime:green)):(oshort<0?purple:(oshort<omed?red:orange))
    barcolor(ebc?bc:na)

     

    cycle-channel-indicator.png cycle-channel-indicator.png
    #120998 quote
    Nicolas
    Keymaster
    Master

    I’ll try to translate it by tomorrow, please remind me if I don’t!

    #121007 quote
    supertiti
    Participant
    Master

    Hola Caotico

    You can try this one :

    //PRC_Hurst Cycle Channel Clone | indicator  10.05.2019
    //Nicolas @ www.prorealcode.com  //Sharing ProRealTime knowledge  //converted from pinescript
    
    // --- settings
    //sclt =  10 //Short Cycle Length
    //mclt =  30 //Medium Cycle Length
    //scm =  1.0 //Short Cycle Multiplier
    //mcm =  3.0 //Medium Cycle Multiplier
    // --- end of settings
    
    src=customclose //Source
    once scl = round(sclt/2)
    once mcl = round(mclt/2)
    
    mascl=wilderaverage[scl](src)
    mamcl=wilderaverage[mcl](src)
    scmoff = scm*averagetruerange[scl]
    mcmoff = mcm*averagetruerange[mcl]
    once scl2=round(scl/2)
    once mcl2=round(mcl/2)
    
    sct =  mascl[scl2]+ scmoff
    scb =  mascl[scl2]- scmoff
    mct =  mamcl[mcl2]+ mcmoff
    mcb =  mamcl[mcl2]- mcmoff
    
    return sct coloured(232,232,232) as "ShortCycleTop", scb coloured(232,232,232) as "ShortCycleBottom", (sct+scb)/2  as "ShortCycleMedian", mct coloured(232,232,232) as "MediumCycleTop", mcb coloured(232,232,232) as "MedianCycleBottom", (mct+mcb)/2  as "MediumCycleMedian" , customclose as " customclose "
    

    Here is the IBEX35

    Where do you live in Spain ? soy de Medina Sidonia

    un saludo

    #121008 quote
    supertiti
    Participant
    Master
    #121013 quote
    caoticoPRC
    Participant
    Junior

    Thanks! No rush 🙂

    #121014 quote
    caoticoPRC
    Participant
    Junior

    Thank you! I of the Balearic Islands. I am still starting at this but the indicator has caught my attention after seeing many, and combining it with the price passed by someone else (eg I have tried VIDYA and CCI) greatly improves the oscillators. The idea would be to use the same thing but transformed into an oscillator.

    #121035 quote
    Nicolas
    Keymaster
    Master

    Here is the code translated from Pinescript into ProRealTime. You have to change the src variable to inject any type of value, in this version it is the Close.

    //PRC_Cycle Channel Oscillator | indicator  03.03.2020
    //Nicolas @ www.prorealcode.com  
    //Sharing ProRealTime knowledge  
    //converted from pinescript
    
    // --- settings
    sclt =  10 //Short Cycle Length
    mclt =  30 //Medium Cycle Length
    scm =  1.0 //Short Cycle Multiplier
    mcm =  3.0 //Medium Cycle Multiplier
    // --- end of settings
    
    src=customclose //Source
    once scl = round(sclt/2)
    once mcl = round(mclt/2)
    
    mascl=wilderaverage[scl](src)
    mamcl=wilderaverage[mcl](src)
    scmoff = scm*averagetruerange[scl]
    mcmoff = mcm*averagetruerange[mcl]
    once scl2=round(scl/2)
    once mcl2=round(mcl/2)
    
    sct =  mascl[scl2]+ scmoff
    scb =  mascl[scl2]- scmoff
    mct =  mamcl[mcl2]+ mcmoff
    mcb =  mamcl[mcl2]- mcmoff
    
    scmm=(sct+scb)/2
    
    omed=(scmm-mcb)/(mct-mcb)
    oshort=(src-mcb)/(mct-mcb)
    
    if omed >=1 then 
    drawsegment(barindex,1,barindex,omed) coloured(128,0,128)
    endif
    if omed <=0 then
    drawsegment(barindex,0,barindex,omed) coloured(128,0,128)
    endif
    if oshort >=1 then
    drawsegment(barindex,1,barindex,oshort) coloured(128,0,128)
    endif
    if oshort <=0 then
    drawsegment(barindex,0,barindex,oshort) coloured(128,0,128)
    endif
    
    return 1.0 coloured(168,168,168) as "UpperLine", 0.5 coloured(168,168,168) as "MidLine", 0.0 coloured(168,168,168) as "LowerLine",oshort coloured(255,0,0) style(line,2) as "FastOsc",omed coloured(0,255,0) style(line,2) as "SlowOsc" 
    //plot(omed>=1.0?omed:na, histbase=1.0, style=histogram, color=purple, linewidth=2, title="MediumCycleOB")
    //plot(omed<=0.0?omed:na, histbase=0.0, style=histogram, color=purple, linewidth=2, title="MediumCycleOS")
    //plot(oshort>=1.0?oshort:na, histbase=1.0, style=histogram, color=purple, linewidth=2, title="ShortCycleOB")
    //plot(oshort<=0.0?oshort:na, histbase=0.0, style=histogram, color=purple, linewidth=2, title="ShortCycleOS"
    cycle-channel-oscillator-trading-view-prorealtime.png cycle-channel-oscillator-trading-view-prorealtime.png
    #121039 quote
    Nicolas
    Keymaster
    Master

    VIDYA version

    //PRC_Cycle Channel Oscillator | indicator  03.03.2020
    //Nicolas @ www.prorealcode.com  
    //Sharing ProRealTime knowledge  
    //converted from pinescript
    
    // --- settings
    sclt =  10 //Short Cycle Length
    mclt =  30 //Medium Cycle Length
    scm =  1.0 //Short Cycle Multiplier
    mcm =  3.0 //Medium Cycle Multiplier
    // --- end of settings
    
    nn=3
    mm=21
    dd=15
    
    PP=totalprice
    
    FF=(std[nn](PP)/std[mm](PP))
    
    if FF<=0 then
    for i = 1 to mm do
    if FF[i]>0 then
    FF1a=FF[i]
    break
    endif
    next
    else
    FF1a=FF
    endif
    
    period = ROUND(dd*FF1a)
    
    if period=0 then
    period=1
    endif
    
    Filt = ExponentialAverage[period](PP)
    
    src=filt //Source
    once scl = round(sclt/2)
    once mcl = round(mclt/2)
    
    mascl=wilderaverage[scl](src)
    mamcl=wilderaverage[mcl](src)
    scmoff = scm*averagetruerange[scl]
    mcmoff = mcm*averagetruerange[mcl]
    once scl2=round(scl/2)
    once mcl2=round(mcl/2)
    
    sct =  mascl[scl2]+ scmoff
    scb =  mascl[scl2]- scmoff
    mct =  mamcl[mcl2]+ mcmoff
    mcb =  mamcl[mcl2]- mcmoff
    
    scmm=(sct+scb)/2
    
    omed=(scmm-mcb)/(mct-mcb)
    oshort=(src-mcb)/(mct-mcb)
    
    if omed >=1 then 
    drawsegment(barindex,1,barindex,omed) coloured(128,0,128)
    endif
    if omed <=0 then
    drawsegment(barindex,0,barindex,omed) coloured(128,0,128)
    endif
    if oshort >=1 then
    drawsegment(barindex,1,barindex,oshort) coloured(128,0,128)
    endif
    if oshort <=0 then
    drawsegment(barindex,0,barindex,oshort) coloured(128,0,128)
    endif
    
    return 1.0 coloured(168,168,168) as "UpperLine", 0.5 coloured(168,168,168) as "MidLine", 0.0 coloured(168,168,168) as "LowerLine",oshort coloured(255,0,0) style(line,2) as "FastOsc",omed coloured(0,255,0) style(line,2) as "SlowOsc" 
    
    #121040 quote
    caoticoPRC
    Participant
    Junior

    tHANKS! Works great, now time to play with it.

    #121076 quote
    caoticoPRC
    Participant
    Junior

    Hi again. The VIDYA I am working with is the other version, the merging gives a smoother pattern. I’ve tried myself to add it up but I haven’t been able to code. It seems it’s not so straight forward to apply an indicator to another independent indicator as I thought.

     

    Thanks!

    //Vi.Dy.A = (Variable Index Dynamic Average)
    
    //period=14
    
    
    if barindex>100 then
    //(Please note: the analyst can set α to be equal to any value, but the quantity (1-α*k) should always be positive).
    k=abs(Chandle[20](close))/100
    alfa=2/(period+1)
    vidya=(alfa*k*close+(1-alfa*k)*vidya[1])
    endif
    
    return vidya
    

     

    #121086 quote
    Nicolas
    Keymaster
    Master

    Here it is:

    //PRC_Cycle Channel Oscillator | indicator  03.03.2020
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //converted from pinescript
    
    // --- settings
    sclt =  10 //Short Cycle Length
    mclt =  30 //Medium Cycle Length
    scm =  1.0 //Short Cycle Multiplier
    mcm =  3.0 //Medium Cycle Multiplier
    // --- end of settings
    
    //Vi.Dy.A = (Variable Index Dynamic Average)
    period=14
    if barindex>100 then
    //(Please note: the analyst can set α to be equal to any value, but the quantity (1-α*k) should always be positive).
    k=abs(Chandle[20](close))/100
    alfa=2/(period+1)
    vidya=(alfa*k*close+(1-alfa*k)*vidya[1])
    endif
    
    src=vidya //Source
    once scl = round(sclt/2)
    once mcl = round(mclt/2)
    
    mascl=wilderaverage[scl](src)
    mamcl=wilderaverage[mcl](src)
    scmoff = scm*averagetruerange[scl]
    mcmoff = mcm*averagetruerange[mcl]
    once scl2=round(scl/2)
    once mcl2=round(mcl/2)
    
    sct =  mascl[scl2]+ scmoff
    scb =  mascl[scl2]- scmoff
    mct =  mamcl[mcl2]+ mcmoff
    mcb =  mamcl[mcl2]- mcmoff
    
    scmm=(sct+scb)/2
    
    omed=(scmm-mcb)/(mct-mcb)
    oshort=(src-mcb)/(mct-mcb)
    
    if omed >=1 then
    drawsegment(barindex,1,barindex,omed) coloured(128,0,128)
    endif
    if omed <=0 then
    drawsegment(barindex,0,barindex,omed) coloured(128,0,128)
    endif
    if oshort >=1 then
    drawsegment(barindex,1,barindex,oshort) coloured(128,0,128)
    endif
    if oshort <=0 then
    drawsegment(barindex,0,barindex,oshort) coloured(128,0,128)
    endif
    
    return 1.0 coloured(168,168,168) as "UpperLine", 0.5 coloured(168,168,168) as "MidLine", 0.0 coloured(168,168,168) as "LowerLine",oshort coloured(255,0,0) style(line,2) as "FastOsc",omed coloured(0,255,0) style(line,2) as "SlowOsc"
    #121091 quote
    caoticoPRC
    Participant
    Junior

    Thanks!

     

    As an example, I attach first image on my desktop now, Oil daily futures:

    The indicators, for comparing purposes, are: Cycle channel oscillator applied to VIDYA, SUperbandpass filer, Wavetrend, and DSS , all with standars inputs.

    In a first impression, I would say, being a relatively slow indicator, it gives clear big picture turning the moving average into an oscillator, signal ranging markets well like the Vidya (in which use another kind of oscillator), and has big divergences in major turning points. Probably it gives interesting results merging with other kind of moving averages, oscillators or price filters.

    Nicolas thanked this post
    Screen-Shot-2020-03-03-at-18.48.44.png Screen-Shot-2020-03-03-at-18.48.44.png
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Request: (Hurst) Cycle Channel Oscillator (LazyBear, Tradingview)


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
caoticoPRC @caoticoprc Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by caoticoPRC
5 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/02/2020
Status: Active
Attachments: 4 files
Logo Logo
Loading...