UDAY_C_Santhakumar

UCS_Squeeze_Momentum_Optimized_Overlay

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

评论:
评论:

Uday C Santhakumar
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
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)