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 open-source

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzarlo gratuitamente, ma il riutilizzo del codice è subordinato al rispetto del Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questo script sui tuoi grafici?
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)