Conversión indicador Gaussian Channel with the Best Setting tradingview
Forums › ProRealTime foro Español › Soporte ProBuilder › Conversión indicador Gaussian Channel with the Best Setting tradingview
- This topic has 2 replies, 2 voices, and was last updated 8 months ago by jesus1975.
Viewing 3 posts - 1 through 3 (of 3 total)
-
-
04/18/2024 at 10:10 AM #231650
Solicito, si es posible, convertir el indicador adjunto. Tiene buena pinta, se adapta muy bien tanto a tendencias cortas como más largas.
https://www.tradingview.com/script/WC5Ekkc9-Gaussian-Channel-with-the-Best-Setting/
Muchas gracias.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Kebeng//@version=4study(title="Gaussian Channel with the Best Setting", shorttitle="GC Best Setting", overlay=true)//Filter functionf_filt9x (_a, _s, _i) =>int _m2 = 0, int _m3 = 0, int _m4 = 0, int _m5 = 0, int _m6 = 0,int _m7 = 0, int _m8 = 0, int _m9 = 0, float _f = .0, _x = (1 - _a)// Weights.// Initial weight _m1 is a pole number and equal to _i_m2 := _i == 9 ? 36 : _i == 8 ? 28 : _i == 7 ? 21 : _i == 6 ? 15 : _i == 5 ? 10 : _i == 4 ? 6 : _i == 3 ? 3 : _i == 2 ? 1 : 0_m3 := _i == 9 ? 84 : _i == 8 ? 56 : _i == 7 ? 35 : _i == 6 ? 20 : _i == 5 ? 10 : _i == 4 ? 4 : _i == 3 ? 1 : 0_m4 := _i == 9 ? 126 : _i == 8 ? 70 : _i == 7 ? 35 : _i == 6 ? 15 : _i == 5 ? 5 : _i == 4 ? 1 : 0_m5 := _i == 9 ? 126 : _i == 8 ? 56 : _i == 7 ? 21 : _i == 6 ? 6 : _i == 5 ? 1 : 0_m6 := _i == 9 ? 84 : _i == 8 ? 28 : _i == 7 ? 7 : _i == 6 ? 1 : 0_m7 := _i == 9 ? 36 : _i == 8 ? 8 : _i == 7 ? 1 : 0_m8 := _i == 9 ? 9 : _i == 8 ? 1 : 0_m9 := _i == 9 ? 1 : 0// filter_f := pow(_a, _i) * nz(_s) +_i * _x * nz(_f[1]) - (_i >= 2 ?_m2 * pow(_x, 2) * nz(_f[2]) : 0) + (_i >= 3 ?_m3 * pow(_x, 3) * nz(_f[3]) : 0) - (_i >= 4 ?_m4 * pow(_x, 4) * nz(_f[4]) : 0) + (_i >= 5 ?_m5 * pow(_x, 5) * nz(_f[5]) : 0) - (_i >= 6 ?_m6 * pow(_x, 6) * nz(_f[6]) : 0) + (_i >= 7 ?_m7 * pow(_x, 7) * nz(_f[7]) : 0) - (_i >= 8 ?_m8 * pow(_x, 8) * nz(_f[8]) : 0) + (_i == 9 ?_m9 * pow(_x, 9) * nz(_f[9]) : 0)//9 var declaration funf_pole (_a, _s, _i) =>_f1 = f_filt9x(_a, _s, 1), _f2 = (_i >= 2 ? f_filt9x(_a, _s, 2) : 0), _f3 = (_i >= 3 ? f_filt9x(_a, _s, 3) : 0)_f4 = (_i >= 4 ? f_filt9x(_a, _s, 4) : 0), _f5 = (_i >= 5 ? f_filt9x(_a, _s, 5) : 0), _f6 = (_i >= 6 ? f_filt9x(_a, _s, 6) : 0)_f7 = (_i >= 2 ? f_filt9x(_a, _s, 7) : 0), _f8 = (_i >= 8 ? f_filt9x(_a, _s, 8) : 0), _f9 = (_i == 9 ? f_filt9x(_a, _s, 9) : 0)_fn = _i == 1 ? _f1 : _i == 2 ? _f2 : _i == 3 ? _f3 :_i == 4 ? _f4 : _i == 5 ? _f5 : _i == 6 ? _f6 :_i == 7 ? _f7 : _i == 8 ? _f8 : _i == 9 ? _f9 : na[_fn, _f1]//-----------------------------------------------------------------------------------------------------------------------------------------------------------------//Inputs//-----------------------------------------------------------------------------------------------------------------------------------------------------------------//Sourcesrc = input(defval=hlc3, title="Source")//Polesint N = input(defval=3, title="Poles", minval=1, maxval=9)//Periodint per = input(defval=100, title="Sampling Period", minval=2)//True Range Multiplierfloat mult = input(defval=2.414, title="Filtered True Range Multiplier", minval=0)//Lag Reductionbool modeLag = input(defval=false, title="Reduced Lag Mode")bool modeFast = input(defval=false, title="Fast Response Mode")//-----------------------------------------------------------------------------------------------------------------------------------------------------------------//Definitions//-----------------------------------------------------------------------------------------------------------------------------------------------------------------//Beta and Alpha Componentsbeta = (1 - cos(4*asin(1)/per)) / (pow(1.414, 2/N) - 1)alpha = - beta + sqrt(pow(beta, 2) + 2*beta)//Laglag = (per - 1)/(2*N)//Datasrcdata = modeLag ? src + (src - src[lag]) : srctrdata = modeLag ? tr(true) + (tr(true) - tr(true)[lag]) : tr(true)//Filtered Values[filtn, filt1] = f_pole(alpha, srcdata, N)[filtntr, filt1tr] = f_pole(alpha, trdata, N)//Lag Reductionfilt = modeFast ? (filtn + filt1)/2 : filtnfilttr = modeFast ? (filtntr + filt1tr)/2 : filtntr//Bandshband = filt + filttr*multlband = filt - filttr*mult// Colorscolor1 = #0aff68color2 = #00752dcolor3 = #ff0a5acolor4 = #990032fcolor = filt > filt[1] ? #0aff68 : filt < filt[1] ? #ff0a5a : #ccccccbarcolor = (src > src[1]) and (src > filt) and (src < hband) ? #0aff68 : (src > src[1]) and (src >= hband) ? #0aff1b : (src <= src[1]) and (src > filt) ? #00752d :(src < src[1]) and (src < filt) and (src > lband) ? #ff0a5a : (src < src[1]) and (src <= lband) ? #ff0a11 : (src >= src[1]) and (src < filt) ? #990032 : #cccccc//-----------------------------------------------------------------------------------------------------------------------------------------------------------------//Outputs//-----------------------------------------------------------------------------------------------------------------------------------------------------------------//Filter Plotfiltplot = plot(filt, title="Filter", color=fcolor, linewidth=3)//Band Plotshbandplot = plot(hband, title="Filtered True Range High Band", color=fcolor)lbandplot = plot(lband, title="Filtered True Range Low Band", color=fcolor)//Channel Fillfill(hbandplot, lbandplot, title="Channel Fill", color=fcolor, transp=80)//Bar Colorbarcolor(barcolor)04/19/2024 at 1:11 PM #231705Hola
Aquí tienes el código traducido:
https://www.prorealcode.com/prorealtime-indicators/gaussian-channel-indicator-key-to-identifying-trends-and-volatility/123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262//-----------------------------------------------------------////PRC_Gaussian Channel//version = 0//19.04.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-----------------------------------------------------------////-----Inputs------------------------------------------------//source=(high+low+close)/3N=4//Polesper=144//Sampling periodmult=1.414//True Range multipliermodelag=0//Boolean//Reduced Lag Modecolorcandle=0//Boolean//Color Candlescolorchannel=1//Boolean//Color Channel//-----------------------------------------------------------////-----Beta and Alpha components-----------------------------//beta = (1-cos(4*asin(1)/per))/(pow(1.414,2/N)-1)alpha = - beta + SQRT(pow(beta,2) + 2*beta)lag = round((per-1)/(2*N))//-----------------------------------------------------------////-----Data--------------------------------------------------//if modelag thenif barindex <= lag thensrc=sourcetrdate=trelsesrc=source+(source-source[lag])trdata=tr+(tr-tr[lag])endifelsesrc=sourcetrdata=trendif//-----------------------------------------------------------////-----Filtered Values---------------------------------------////[filtn, filt1] = f_pole(alpha, srcdata, N)//f_filt9x (alpha, srcdata, N)x=1-alphaif N=9 thenm2=36m3=84m4=126m5=126m6=84m7=36m8=9m9=1elsif N=8 thenm2=28m3=56m4=70m5=56m6=28m7=8m8=1m9=0elsif N=7 thenm2=21m3=35m4=35m5=21m6=7m7=1m8=0m9=0elsif N=6 thenm2=15m3=20m4=15m5=6m6=1m7=0m8=0m9=0elsif N=5 thenm2=10m3=10m4=5m5=1m6=0m7=0m8=0m9=0elsif N=4 thenm2=6m3=4m4=1m5=0m6=0m7=0m8=0m9=0elsif N=3 thenm2=3m3=1m4=0m5=0m6=0m7=0m8=0m9=0elsif N=2 thenm2=1m3=0m4=0m5=0m6=0m7=0m8=0m9=0endifif barindex <=N thenf1=0f2=0f3=0f4=0f5=0f6=0f7=0f8=0f9=0filtN=0filttrN=0elseif N=9 thenf9= pow(alpha,N) * src+N*x*f9[1] - m2*pow(x,2)*f9[2] + m3*pow(x,3)*f9[3] - m4*pow(x,4)*f9[4] + m5*pow(x,5)*f9[5] - m6*pow(x,6)*f9[6] + m7*pow(x,7)*f9[7] - m8*pow(x,8)*f9[8] + m9*pow(x,9)*f9[9]filtN=f9ftr9= pow(alpha,N) * trdata+N*x*ftr9[1] - m2*pow(x,2)*ftr9[2] + m3*pow(x,3)*ftr9[3] - m4*pow(x,4)*ftr9[4] + m5*pow(x,5)*ftr9[5] - m6*pow(x,6)*ftr9[6] + m7*pow(x,7)*ftr9[7] - m8*pow(x,8)*ftr9[8] + m9*pow(x,9)*ftr9[9]filttrN=ftr9elsif N=8 thenf8= pow(alpha,N) * src+N*x*f8[1] - m2*pow(x,2)*f8[2] + m3*pow(x,3)*f8[3] - m4*pow(x,4)*f8[4] + m5*pow(x,5)*f8[5] - m6*pow(x,6)*f8[6] + m7*pow(x,7)*f8[7] - m8*pow(x,8)*f8[8]filtN=f8ftr8= pow(alpha,N) * trdata+N*x*ftr8[1] - m2*pow(x,2)*ftr8[2] + m3*pow(x,3)*ftr8[3] - m4*pow(x,4)*ftr8[4] + m5*pow(x,5)*ftr8[5] - m6*pow(x,6)*ftr8[6] + m7*pow(x,7)*ftr8[7] - m8*pow(x,8)*ftr8[8]filttrN=ftr8elsif N=7 thenf7= pow(alpha,N) * src+N*x*f7[1] - m2*pow(x,2)*f7[2] + m3*pow(x,3)*f7[3] - m4*pow(x,4)*f7[4] + m5*pow(x,5)*f7[5] - m6*pow(x,6)*f7[6] + m7*pow(x,7)*f7[7]filtN=f7ftr7= pow(alpha,N) * trdata+N*x*ftr7[1] - m2*pow(x,2)*ftr7[2] + m3*pow(x,3)*ftr7[3] - m4*pow(x,4)*ftr7[4] + m5*pow(x,5)*ftr7[5] - m6*pow(x,6)*ftr7[6] + m7*pow(x,7)*ftr7[7]filttrN=ftr7elsif N=6 thenf6= pow(alpha,N) * src+N*x*f6[1] - m2*pow(x,2)*f6[2] + m3*pow(x,3)*f6[3] - m4*pow(x,4)*f6[4] + m5*pow(x,5)*f6[5] - m6*pow(x,6)*f6[6]filtN=f6ftr6= pow(alpha,N) * trdata+N*x*ftr6[1] - m2*pow(x,2)*ftr6[2] + m3*pow(x,3)*ftr6[3] - m4*pow(x,4)*ftr6[4] + m5*pow(x,5)*ftr6[5] - m6*pow(x,6)*ftr6[6]filttrN=ftr6elsif N=5 thenf5= pow(alpha,N) * src+N*x*f5[1] - m2*pow(x,2)*f5[2] + m3*pow(x,3)*f5[3] - m4*pow(x,4)*f5[4] + m5*pow(x,5)*f5[5]filtN=f5ftr5= pow(alpha,N) * trdata+N*x*ftr5[1] - m2*pow(x,2)*ftr5[2] + m3*pow(x,3)*ftr5[3] - m4*pow(x,4)*ftr5[4] + m5*pow(x,5)*ftr5[5]filttrN=ftr5elsif N=4 thenf4= pow(alpha,N) * src+N*x*f4[1] - m2*pow(x,2)*f4[2] + m3*pow(x,3)*f4[3] - m4*pow(x,4)*f4[4]filtN=f4ftr4= pow(alpha,N) * trdata+N*x*ftr4[1] - m2*pow(x,2)*ftr4[2] + m3*pow(x,3)*ftr4[3] - m4*pow(x,4)*ftr4[4]filttrN=ftr4elsif N=3 thenf3= pow(alpha,N) * src+N*x*f3[1] - m2*pow(x,2)*f3[2] + m3*pow(x,3)*f3[3]filtN=f3ftr3= pow(alpha,N) * trdata+N*x*ftr3[1] - m2*pow(x,2)*ftr3[2] + m3*pow(x,3)*ftr3[3]filttrN=ftr3elsif N=2 thenf2= pow(alpha,N) * src+N*x*f2[1] - m2*pow(x,2)*f2[2]filtN=f2ftr2= pow(alpha,N) * trdata+N*x*ftr2[1] - m2*pow(x,2)*ftr2[2]filttrN=ftr2elsif N=1 thenf1= pow(alpha,N) * src+N*x*f1[1]filtN=f1ftr1= pow(alpha,N) * trdata+N*x*ftr1[1]filttrN=ftr1endifendiffilt=filtNfiltTR=filttrN//-----------------------------------------------------------////-----Bands-------------------------------------------------//hband=filt+filtTR*multlband=filt-filtTR*mult//-----------------------------------------------------------////-----Bands Colors------------------------------------------//if filt > filt[1] thenr=10g=255b=104elsif filt<filt[1] thenr=255g=10b=90elser=204g=204b=204endif//-----------------------------------------------------------////-----Candle Colors-----------------------------------------//if colorcandle thenif source > source[1] and source>filt and source < hband thenrb=10gb=255bb=104elsif source > source[1] and source >= hband thenrb=10gb=255bb=27elsif source <= source[1] and source > filt thenrb=0gb=117bb=45elsif source < source[1] and source < filt and source > lband thenrb=255gb=10bb=90elsif source < source[1] and source <= lband thenrb=255gb=10bb=17elsif source >= source[1] and source < filt thenrb=153gb=0bb=50elserb=204gb=204bb=204endifDRAWCANDLE(open, high, low, close) coloured(rb,gb,bb)endif//-----------------------------------------------------------////-----Channel fill color------------------------------------//if colorchannel thencolorbetween(hband,lband,r,g,b,80)endif//-----------------------------------------------------------//return hband as "Filtered TR High Band"coloured(r,g,b), lband as "Filtered TR Low Band"coloured(r,g,b),filt as "Filter"coloured(r,g,b)style(line,3)1 user thanked author for this post.
04/19/2024 at 3:07 PM #231706 -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
Find exclusive trading pro-tools on
Similar topics: