Hi guys, please find here the TTM squeeze pro. This updated version of the TTM squeeze now includes 3 levels of squeeze, low, mid and high compression rather than the previous mid squeeze only. It also includes the momentum histogram. Thanks to JS who helped with parts of the code.
length=20
lengthkc=20
mult=2.0
DonchianMidline = (Highest[20](high)+Lowest[20](low)+Average[20](close) )/3
sma=close-(DonchianMidline)
Delta = linearregression[20](sma)
basis = exponentialaverage[length](close)
dev = mult * Std[length](close)
BBup = basis + dev
BBdn = basis - dev
//KC
ma = exponentialaverage[lengthkc](close)
myrange = averagetruerange[14]
KC2up = ma+myrange * 2
KC2dn = ma-myrange * 2
KC15up = ma+myrange * 1.5
KC15dn = ma-myrange * 1.5
KC1up = ma+myrange * 1
KC1dn = ma-myrange * 1
sqzOnlow = (bbup<kc2up) and (bbup>kc15up) and (bbdn>kc2dn) and (bbdn<kc15dn)
sqzOnmid = (bbup<kc15up) and (bbup>kc1up) and (bbdn>kc15dn) and (bbdn<kc1dn)
sqzOnhigh = (bbup<kc1up) and (bbdn>kc1dn)
if sqzOnlow then
DrawPoint(BarIndex,0,3)Coloured(255,255,255)
//AcolorR = 255
//AcolorG = 255
//AcolorB= 255
else
//DrawPoint(BarIndex,0,3)Coloured(255,0,0)
//colorR = 255
//colorG = 0
//COLORB=0
endif
if sqzOnmid then
DrawPoint(BarIndex,0,3)Coloured(0,255,0)
//BcolorR = 0
//BcolorG = 255
//BcolorB= 0
else
//DrawPoint(BarIndex,0,3)Coloured(255,0,0)
//colorR = 255
//colorG = 0
//COLORB=0
ENDIF
if sqzOnhigh then
DrawPoint(BarIndex,0,3)Coloured(0,0,255)
//CcolorR = 0
//CcolorG = 0
//CcolorB= 255
else
//DrawPoint(BarIndex,0,3)Coloured(255,0,0)
//colorR = 255
//colorG = 0
//COLORB=0
ENDIF
If BBUP > KC2UP AND BBDN<KC2DN then
DrawPoint(BarIndex,0,3)Coloured("Red")
EndIf
//histogram modifications
if delta>0 and delta>delta[1] then
plusI = delta
plusD = 0
minusI = 0
minusD = 0
colorR=0
colorG=245
colorB=255
elsif delta>0 and delta<delta[1] then
plusI = 0
plusD = delta
minusI = 0
minusD = 0
colorR=0
colorG=0
colorB=255
elsif delta<0 and delta<delta[1] then
plusI = 0
plusD = 0
minusI = 0
minusD = delta
colorR=255
colorG=0
colorB=0
elsif delta<0 and delta>delta[1] then
plusI = 0
plusD = 0
minusI = delta
minusD = 0
colorR=255
colorG=255
colorB=0
endif
RETURN plusI coloured(colorR,colorG,colorB) style(histogram,1) as "plus increase", plusD coloured(colorR,colorG,colorB) style(histogram,1) as "plus decrease", minusI coloured(colorR,colorG,colorB) style(histogram,1) as "minus increase", minusD coloured(colorR,colorG,colorB) style(histogram,1) as "minus decrease"
Enjoy!