Request: (Hurst) Cycle Channel Oscillator (LazyBear, Tradingview)
Forums › ProRealTime English forum › ProBuilder support › Request: (Hurst) Cycle Channel Oscillator (LazyBear, Tradingview)
- This topic has 11 replies, 3 voices, and was last updated 4 years ago by caoticoPRC.
-
-
03/02/2020 at 4:20 PM #120980
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:
123456789101112131415161718192021222324252627282930313233//// @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/2ma_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/2sct = nz(ma_scl[scl_2], src)+ scm_offscb = nz(ma_scl[scl_2], src)- scm_offmct = nz(ma_mcl[mcl_2], src)+ mcm_offmcb = nz(ma_mcl[mcl_2], src)- mcm_offscmm=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)03/02/2020 at 6:19 PM #12099803/02/2020 at 7:38 PM #121007Hola Caotico
You can try this one :
PRC_Hurst Cycle Channel Clone123456789101112131415161718192021222324252627//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 settingssrc=customclose //Sourceonce 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]+ scmoffscb = mascl[scl2]- scmoffmct = mamcl[mcl2]+ mcmoffmcb = mamcl[mcl2]- mcmoffreturn 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
03/02/2020 at 7:43 PM #12100803/02/2020 at 9:31 PM #12101303/02/2020 at 9:33 PM #121014Thank 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.
03/03/2020 at 9:50 AM #121035Here 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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051//PRC_Cycle Channel Oscillator | indicator 03.03.2020//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//converted from pinescript// --- settingssclt = 10 //Short Cycle Lengthmclt = 30 //Medium Cycle Lengthscm = 1.0 //Short Cycle Multipliermcm = 3.0 //Medium Cycle Multiplier// --- end of settingssrc=customclose //Sourceonce 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]+ scmoffscb = mascl[scl2]- scmoffmct = mamcl[mcl2]+ mcmoffmcb = mamcl[mcl2]- mcmoffscmm=(sct+scb)/2omed=(scmm-mcb)/(mct-mcb)oshort=(src-mcb)/(mct-mcb)if omed >=1 thendrawsegment(barindex,1,barindex,omed) coloured(128,0,128)endifif omed <=0 thendrawsegment(barindex,0,barindex,omed) coloured(128,0,128)endifif oshort >=1 thendrawsegment(barindex,1,barindex,oshort) coloured(128,0,128)endifif oshort <=0 thendrawsegment(barindex,0,barindex,oshort) coloured(128,0,128)endifreturn 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"03/03/2020 at 9:54 AM #121039VIDYA version
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374//PRC_Cycle Channel Oscillator | indicator 03.03.2020//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//converted from pinescript// --- settingssclt = 10 //Short Cycle Lengthmclt = 30 //Medium Cycle Lengthscm = 1.0 //Short Cycle Multipliermcm = 3.0 //Medium Cycle Multiplier// --- end of settingsnn=3mm=21dd=15PP=totalpriceFF=(std[nn](PP)/std[mm](PP))if FF<=0 thenfor i = 1 to mm doif FF[i]>0 thenFF1a=FF[i]breakendifnextelseFF1a=FFendifperiod = ROUND(dd*FF1a)if period=0 thenperiod=1endifFilt = ExponentialAverage[period](PP)src=filt //Sourceonce 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]+ scmoffscb = mascl[scl2]- scmoffmct = mamcl[mcl2]+ mcmoffmcb = mamcl[mcl2]- mcmoffscmm=(sct+scb)/2omed=(scmm-mcb)/(mct-mcb)oshort=(src-mcb)/(mct-mcb)if omed >=1 thendrawsegment(barindex,1,barindex,omed) coloured(128,0,128)endifif omed <=0 thendrawsegment(barindex,0,barindex,omed) coloured(128,0,128)endifif oshort >=1 thendrawsegment(barindex,1,barindex,oshort) coloured(128,0,128)endifif oshort <=0 thendrawsegment(barindex,0,barindex,oshort) coloured(128,0,128)endifreturn 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"03/03/2020 at 10:02 AM #121040tHANKS! Works great, now time to play with it.
03/03/2020 at 2:16 PM #121076Hi 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!
vidya12345678910111213//Vi.Dy.A = (Variable Index Dynamic Average)//period=14if 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))/100alfa=2/(period+1)vidya=(alfa*k*close+(1-alfa*k)*vidya[1])endifreturn vidya03/03/2020 at 5:08 PM #121086Here it is:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556//PRC_Cycle Channel Oscillator | indicator 03.03.2020//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//converted from pinescript// --- settingssclt = 10 //Short Cycle Lengthmclt = 30 //Medium Cycle Lengthscm = 1.0 //Short Cycle Multipliermcm = 3.0 //Medium Cycle Multiplier// --- end of settings//Vi.Dy.A = (Variable Index Dynamic Average)period=14if 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))/100alfa=2/(period+1)vidya=(alfa*k*close+(1-alfa*k)*vidya[1])endifsrc=vidya //Sourceonce 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]+ scmoffscb = mascl[scl2]- scmoffmct = mamcl[mcl2]+ mcmoffmcb = mamcl[mcl2]- mcmoffscmm=(sct+scb)/2omed=(scmm-mcb)/(mct-mcb)oshort=(src-mcb)/(mct-mcb)if omed >=1 thendrawsegment(barindex,1,barindex,omed) coloured(128,0,128)endifif omed <=0 thendrawsegment(barindex,0,barindex,omed) coloured(128,0,128)endifif oshort >=1 thendrawsegment(barindex,1,barindex,oshort) coloured(128,0,128)endifif oshort <=0 thendrawsegment(barindex,0,barindex,oshort) coloured(128,0,128)endifreturn 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"03/03/2020 at 6:53 PM #121091Thanks!
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.
1 user thanked author for this post.
-
AuthorPosts