AlfyParticipant
Average
Good morning guys, I’m trying to create the TTM Squeeze pro. The code already exists on site for the basic TTM squeeze which is when the Bollinger 20 day bands with 2 standard deviations around a 20d SMA move inside the 20d Keltner channels with 1.5 average true ranges (14d) around a 20d SMA. What I’ve tried to create is the squeeze pro which has 3 levels of compression. The lowest compression is when the Bollinger bands move inside the Keltner channels with 2 ATRs around the 20d SMA, the mid squeeze is when the Bollinger’s move inside the 1.5 ATR Keltner channels and finally the high compression squeeze is when the Bollinger’s move inside the Keltner’s with 1 ATR around the 20d SMA. I’ve tried to colour the dots white for the low compression sqz, Green for the mid compression and Blue for the high compression squeeze but the dots aren’t coming out coloured correctly. The rest looks ok. Can someone take a look at the code to see where I’m going wrong? Any help most appreciated.
Best regards
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)
upperBB = basis + dev
lowerBB = basis - dev
//KC
ma = exponentialaverage[lengthkc](close)
myrange = averagetruerange[14]
upperKClow = ma+myrange * 2
lowerKClow = ma-myrange * 2
upperKCmid = ma+myrange * 1.5
lowerKCmid = ma-myrange * 1.5
upperKChigh = ma+myrange * 1
lowerKChigh = ma-myrange * 1
sqzOnlow = (lowerBB>lowerKClow) AND (upperBB<upperKClow) AND (LOWERBB<LOWERKCMID) AND (UPPERBB>UPPERKCMID)
sqzOnmid = (lowerBB>lowerKCmid) AND (upperBB<upperKCmid) AND (LOWERBB<LOWERKCHIGH) AND (LOWERBB>UPPERKCHIGH)
sqzOnhigh = (lowerBB>lowerKChigh) AND (upperBB<upperKChigh)
if(sqzOnlow=1) then
scolorR = 255
scolorG = 255
scolorB= 255
else
scolorR = 255
scolorG = 0
ENDIF
if(sqzOnmid=1) then
scolorR = 0
scolorG = 255
scolorB= 0
else
scolorR = 255
scolorG = 0
ENDIF
if(sqzOnhigh=1) then
scolorR = 0
scolorG = 0
scolorB=255
else
scolorR = 255
scolorG = 0
ENDIF
if delta>0 then
sqz=-squeezeDotsOffset*pointsize
else
sqz=squeezeDotsOffset*pointsize
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", sqz coloured(scolorR,scolorG,0) style(point,5) as "squeeze momentum"
Hi,
Line 19 doesn’t feel right, you could try replacing the lowerbb towards the end of the line with upperbb:
sqzOnmid = (lowerBB>lowerKCmid) AND (upperBB<upperKCmid) AND (LOWERBB<LOWERKCHIGH) AND (UPPERBB>UPPERKCHIGH)
AlfyParticipant
Average
Very good spot thank you.
arParticipant
Junior
Bonjour
Quand je télécharge le screener j’ai un message d’erreur ” Veuillez définir la variable suivante : length, lengthkc, mult, squeezeDotsOffset “
Merci pour votre retour
Hello When I download the screener I get an error message “Please define the following variable: length, lengthkc, mult, squeezeDotsOffset” Thank you for your feedback
@ar
Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums. Thanks 🙂