iamajeya

Squeeze Momentum Indicator [AJ]

122
Modified LazyBear's indicator to display on top of price. This makes visualizing it much easier and allows you to clearly focus on price action along with the squeeze.

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?
// Re-written by AJ to show on main chart
// Original @author LazyBear 
// List of all my indicators: https://www.tradingview.com/v/4IneGo8h/
//
study(shorttitle = "AJ_SQZMOM", title="Squeeze Momentum Indicator [AJ]", overlay=true)

length = input(20, title="BB Length")
mult = input(2.0,title="BB MultFactor")
lengthKC=input(20, title="KC Length")
multKC = input(1.5, title="KC MultFactor")

useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)

// Calculate BB
source = close
basis = sma(source, length)
dev = mult * stdev(source, length)
upperBB = basis + dev
lowerBB = basis - dev

// Calculate KC
ma = sma(source, lengthKC)
range = useTrueRange ? tr : (high - low)
rangema = sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC

sqzOn  = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz  = (sqzOn == false) and (sqzOff == false)

val = linreg(source  -  avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)), 
            lengthKC,0)

bcolor = iff( val > 0, 
            iff( val > nz(val[1]), lime, green),
            iff( val < nz(val[1]), red, maroon))
scolor = noSqz ? blue : sqzOn ? black : gray 

kccolor = noSqz ? white : sqzOn ? fuchsia : blue
bbcolor = noSqz ? white : sqzOn ? fuchsia : green
sqzwidth = noSqz ? 2 : 4
//plot(val, color=bcolor, style=histogram, linewidth=4)
//plot(0, color=scolor, style=cross, linewidth=2)

// plot KC and BB
plot(ma, title="Keltner Channel MA", color=kccolor, style=line, linewidth=1, transp=80)
plot(upperKC, title="Keltner Channel Upper Line", color=kccolor, style=line, linewidth=2, transp=70)
plot(lowerKC, title="Keltner Channel Lower Line", color=kccolor, style=line, linewidth=2, transp=70)

plot(basis, title="Bollinger Band Mean", color=bbcolor, style=line, linewidth=1, transp=80 )
plot(upperBB, title="Bollinger Band Upper Band", color=bbcolor, style=line, linewidth=2, transp=70)
plot(lowerBB, title="Bollinger Band Lower Band", color=bbcolor, style=line, linewidth=2, transp=70)