UDAY_C_Santhakumar

UCS_Squeeze_Momentum_Optimized_Overlay

Squeeze Overlay Indicator - Save some screen real estate.
1. Further Optimized Version
Comment:
Finally the Squeeze Trigger Indicator is coming to a good position to trade. A bit more tweaks needed.

Comment:
Comment:

Uday C Santhakumar
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study(shorttitle = "UCS_SQUEEZE", title="UCS_Squeeze_Momentum_Optimized_Overlay", overlay=true)

length = input(20, title="Squeeze Length")
multBB = input(2,title="BB MultFactor")
multKC = input(1.5, title="KC MultFactor")
smooth = input(20, title = "Momentum Smoothing")

usebbr = input(true, title = "Use Bollinger Band Ratio Instead of Momentum", type = bool)
useHAC = input(true, title = "Heikin Ashi Optimization", type=bool)

// Heikin Ashi ATR Calculations
haclose = ohlc4
haopen = na(haopen[1]) ? (open + close)/2 : (haopen[1] + haclose[1]) / 2
hahigh = max (high, max(haopen,haclose))
halow = min (low, min(haopen,haclose))
haatra = abs(hahigh - haclose[1])
haatrb = abs(haclose[1] - halow)
haatrc = abs(hahigh - halow)
haatr = max(haatra, max(haatrb,haatrc))

source = useHAC ? haclose : close

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


// Calculate KC
ma = sma(source, length)
range = useHAC ? haatr : tr
rangema = sma(range, length)
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)

// Momentum ======> %B Indicator OR Rate of Change (ROC)
momentum = usebbr ? (((source - lowerBB)/(upperBB - lowerBB))-0.5) : (((close - close[12])/close[12])*100)
val = sma(momentum,smooth)

scolor = noSqz ? blue : sqzOn ? red : green 

// Background Highlight
bgcolor(scolor)
// Momentum arrows
positiveup = (val > 0) and (val > val[1])
positivedn = (val > 0) and (val < val[1])
negativedn = (val < 0) and (val < val[1])
negativeup = (val < 0) and (val > val[1])

plotshape (positiveup ? positiveup : na, title = "Momentum Positive & Up", style = shape.triangleup, location = location.top, color = green)
plotshape (positivedn ? positivedn : na, title = "Momentum Positive & Down", style = shape.triangledown, location = location.top, color = blue)
plotshape (negativeup ? negativeup : na, title = "Momentum Negative & Up", style = shape.triangleup, location = location.bottom, color = orange)
plotshape (negativedn ? negativedn : na, title = "Momentum Negative & Down", style = shape.triangledown, location = location.bottom, color = red)