fryguy
New member
Here is a Squeeze Indicator that resembles TTM_Squeeze of John Carter
Link: https://researchtrade.com/forum/read.php?7,2258,page=59#:~:text=Here is a Squeeze Indicator that resemble to TTM_Squeez of John Carter
Link: https://researchtrade.com/forum/read.php?7,2258,page=59#:~:text=Here is a Squeeze Indicator that resemble to TTM_Squeez of John Carter
Ruby:
declare lower;
Input Length = 20; # Length for Avg True Range & Std. Dev Calcs
Input Price = Close; # type of price to use
Input minPriceMove = 1; # for scaling
Input priceIncrement = 0.01;
Input nK = 1.5; # Keltner Channel ATRs from Average
Input nBB = 2; # Bollinger Band Std. Devs. from Average
Input AlertLine = 1; # BBS_Index level at which to issue alerts
Input SqueezeOnColor = 2;
Input SqueezeOffColor = 6;
# scaling factor :
def LHMult = if (priceIncrement <> 0, (minPriceMove/priceIncrement), 0);
# Average True Range
def ATR = AvgTrueRange(high, close, low, Length);
# Standard Deviation
def SDev = stdev(Price, Length);
# -- Calculate Bollinger Band Squeeze Indicator --
# for alert
def Denom = (nK*ATR);
def BBS_Ind = if (Denom <> 0, ((nBB * SDev) /Denom), 0);
# -- Plot the Index & Alert Line -------------------------
plot BBS_Index = 0;
BBS_Index.assignValueColor(if BBS_Ind < Alertline then Color.Red else Color.Blue);
BBS_Index.SetStyle(4);
BBS_Index.SetLineWeight(2);
# --------------------------------------------------------
# -- Plot delta of price from Donchian mid line ----------
# Inertia = LinearRegValue
def LinearRegValue = Inertia(price-((Highest(high, Length)+Lowest(low, Length))/2 + ExpAverage(close,Length))/2,Length);
#Plot the Green Values
def LRVGreens = if (LinearRegValue >= 0, LinearRegValue, 0);
plot BBSqueeze_Pos = LRVGreens * LHMult;
BBSqueeze_Pos.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BBSqueeze_Pos.assignValueColor(if LRVGreens > LRVGreens[1] then Color.Green else Color.Dark_Green);
BBSqueeze_Pos.SetLineWeight(2);
#Plot the Red Values
def LRVReds = if (LinearRegValue < 0, LinearRegValue, 0);
plot BBSqueeze_Neg = LRVReds * LHMult;
BBSqueeze_Neg.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BBSqueeze_Neg.assignValueColor(if LRVReds < LRVReds[1] then Color.Red else Color.Dark_Red);
BBSqueeze_Neg.SetLineWeight(2);
#Show Alert Dots
# SQUEEZE ON
def BBS_CrossOverAlert = if (BBS_Ind > BBS_Ind[1] and (BBS_Ind > AlertLine) and (BBS_Ind[1] < AlertLine), (LRVGreens * LHMult + 150 * minPriceMove), 0);
plot CrossOverAlert = if BBS_CrossOverAlert > 0 then BBS_CrossOverAlert else Double.NaN;
CrossOverAlert.SetPaintingStrategy(PaintingStrategy.POINTS);
CrossOverAlert.SetLineWeight(4);
CrossOverAlert.assignValueColor(Color.Light_green);
CrossOverAlert.assignValueColor(GetColor(SqueezeOnColor));
# Alert("BB Squeeze Alert");
def BBS_CrossUnderAlert = if (BBS_Ind < BBS_Ind[1] and (BBS_Ind < AlertLine) and (BBS_Ind[1] > AlertLine), (LRVReds * LHMult - 150 * minPriceMove), 0);
plot CrossUnderAlert = if BBS_CrossUnderAlert < 0 then BBS_CrossUnderAlert else Double.NaN;
CrossUnderAlert.SetPaintingStrategy(PaintingStrategy.POINTS);
CrossUnderAlert.SetLineWeight(4);
CrossUnderAlert.assignValueColor(GetColor(SqueezeOffColor)); # Color.Light_red);
#-----------------------------------------------------------end of code
Last edited by a moderator: