trading.kay27

Kay_BBands v2

This is the second version of Kay_BBands. But this is infused with ADX.

When +DI (Directional Index) is above -DI, then Upper band will be visible and vice-versa.
This is when the ADX is above the threshold. 20 is the default but can be set to 25.

When the ADX is below the specified threshold, both bands gets visible, showing no trending conditions.

Use it with another band with setting 20/21, 0.6 deviation. Prices keeping above or below the 2nd bands upper or lower bounds shows trending conditions.

Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?
//version=2
//2nd version of the band
study(shorttitle="Kay_BBv2", title="Kay_BBands", overlay=true)
length = input(21, minval=1)
hl = input(true, title="Band source as high/low ?", type=bool)
Usrc = hl ? high : close // input(high/Low, title="Upper Src")
Lsrc = hl ? low : close //input(low, title="Lower Src")
mult = input(2.0, minval=0.001, maxval=50)
basis = input(true, title="Use EMA ?", type=bool) ? ema(close, length) : sma(close, length)
//dev = mult * stdev(src, length)
isU = close > basis// and close > basis
//isBetween = (open > basis and close < basis) or (open < basis and close > basis)
isD = close < basis//open < basis and close < basis

upperB = basis + (mult * stdev(Usrc, length))
lowerB = basis - (mult * stdev(Lsrc, length))

upper = isU and highest(Usrc, length) == Usrc ? upperB : upperB < fixnan(upper[1]) ? upperB : fixnan(upper[1])
lower = isD and lowest(Lsrc, length) == Lsrc ? lowerB : lowerB > fixnan(lower[1]) ? lowerB : fixnan(lower[1])

//Adx
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
	up = change(high)
	down = -change(low)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
	minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
	[plus, minus]

adx(dilen, adxlen) => 
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

[plus1, minus1] = dirmov(dilen)
sig = adx(dilen, adxlen)
level = input(20, title="ADX level", minval = 1)

plot(basis, color=sig > level ? red : blue, title="BB Basis")
p1 = plot(upper, color=black, title="BB Upper modified", transp=0)
p2 = plot(lower, color=black, title="BB Lower modified", transp=0)
fill(p1, p2, color=blue, transp=90, title="Modified")

p3 = plot(upperB, color=sig > 20 ? (plus1 > minus1 ? green : na) : blue, title="BB Upper", transp=0)
p4 = plot(lowerB, color=sig > 20 ? (plus1 < minus1 ? green : na) : blue, title="BB Lower", transp=0)
fill(p3, p4, color=blue, transp=95, title="Background")