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...
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?
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)