RicardoSantos

[RS]JR Flex Donchian Channel V0R1

Experimental:
Request for JR, fixed some stuff...
erroneous functions using highest() when it should be lowest()
missing midline...
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?
study("[RS]JR Flex Donchian Channel V0R1", overlay=true)
BB_Length = input(title='BB Length', type=integer, defval=10)
BB_Deviations = input(title='BB Deviations', type=integer, defval=2)
BB_Src = input(title='Source', type=source, defval=close)
//  ||---   BB
BB_Midline = sma(BB_Src, BB_Length)
BB_Deviation = stdev(BB_Src, BB_Length) * BB_Deviations
BB_Upper = BB_Midline + BB_Deviation
BB_Lower = BB_Midline - BB_Deviation
//  ||---   BBW
BB_Width = ((BB_Upper-BB_Lower) / BB_Midline)
//  ||---   DC
DC_Upper = BB_Width <= .025 ? highest(49) :
        BB_Width > .025 and BB_Width <= .050 ? highest(40) :
        BB_Width > .050 and BB_Width <= .075 ? highest(30) :
        BB_Width > .075 and BB_Width <= .100 ? highest(20) :
        BB_Width > .100 and BB_Width <= .125 ? highest(10) :
        BB_Width > .125 and BB_Width <= .150 ? highest(7) :
        BB_Width > .150 ? highest(3) : highest(2)

DC_Lower = BB_Width <= .025 ? lowest(49) :
        BB_Width > .025 and BB_Width <= .050 ? lowest(40) :
        BB_Width > .050 and BB_Width <= .075 ? lowest(30) :
        BB_Width > .075 and BB_Width <= .100 ? lowest(20) :
        BB_Width > .100 and BB_Width <= .125 ? lowest(10) :
        BB_Width > .125 and BB_Width <= .150 ? lowest(7) :
        BB_Width > .150 ? lowest(3) : lowest(2)

pU = plot(DC_Upper, color=blue)
pL = plot(DC_Lower, color=blue)
pM = plot(avg(DC_Upper, DC_Lower), color=black)
fill(pU, pM, color=olive, transp=70)
fill(pL, pM, color=orange, transp=70)