This is a creative way to use Bollinger bands to spot the trend. I added the red/orange clouds for squeeze areas where trend is flat. Notice the arrows. They are triggered when price breaks outside the inner shaded bands. This indicator is best on 5 min or more timeframe.
The below picture is /NQ on the 5M. Highlighted the squeeze zones. The Cyan line is a 20 SMA. I use it for confirmation. Works great on the Daily chart. Typically when an arrow triggers, the next day will follow the arrow's direction.
Link Download: http://tos.mx/Vwdvqqd
The below picture is /NQ on the 5M. Highlighted the squeeze zones. The Cyan line is a 20 SMA. I use it for confirmation. Works great on the Daily chart. Typically when an arrow triggers, the next day will follow the arrow's direction.
Link Download: http://tos.mx/Vwdvqqd
Code:
#Trend Spotter
#assembled by Chewie 10-10-2023
input price = close;
input displace = 0;
input length = 10;
input Num_Dev_Dn = -0.80;
input Num_Dev_up = 0.80;
input Num_Dev_Dn2 = -2.3;
input Num_Dev_up2 = 2.3;
input averageType = AverageType.Simple;
input arrows = yes;
input paintbars = yes;
def sDev = stdev(data = price[-displace], length = length);
plot MidLine = MovingAverage(averageType, data = price[-displace], length = length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;
plot LowerBand2 = MidLine + num_Dev_Dn2 * sDev;
plot UpperBand2 = MidLine + num_Dev_Up2 * sDev;
MidLine.AssignValueColor(if MidLine > MidLine[1] then Color.GREEN else Color.red);
LowerBand.AssignValueColor(if MidLine > MidLine[1] then Color.GREEN else Color.red);
UpperBand.AssignValueColor(if MidLine > MidLine[1] then Color.GREEN else Color.red);
Upperband2.setDefaultColor(color.gray);
Lowerband2.setDefaultColor(color.gray);
def UP = MidLine > MidLine[1];
def DOWN = MidLine < MidLine[1];
#AddCloud(Upperband, LowerBand, Color.DARK_GRAY, Color.DARK_GRAY);
def cloud1_top = if UP then Upperband else double.nan;
def cloud2_top = if DOWN then Lowerband else double.nan;
addcloud(cloud1_top, LowerBand, color. dark_green);
addcloud(Upperband, cloud2_top, color. dark_red);
plot DownSignal = if arrows and close crosses below LowerBand then 1 else 0;
plot UpSignal = if arrows and close crosses above Upperband then 1 else 0;
UpSignal.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_up);
DownSignal.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_down);
UpSignal.SetDefaultColor(Color.GREEN);
DownSignal.SetDefaultColor(Color.RED);
UPSIGNAL.HideTitle();
DOWNSIGNAL.HideTitle();
UPSIGNAL.setLineWeight(2);
DOWNSIGNAL.setLineWeight(2);
AssignPriceColor(if PaintBars and Upsignal then color.green else if paintbars and down then Color.RED else if paintbars and downsignal then color.red else if paintbars and up then Color.GREEN else Color.CURRENT);
#SimpleMovingAvg 20
def length1 = 20;
plot SMA = Average(price[-displace], length1);
SMA.SetDefaultColor(color.cyan);
SMA.setlineweight(2);
SMA.HideTitle();
#SQUEEZE
input KELTNER_Lines = yes;
def factorH = 1.0;
def factorM = 1.5;
def trueRangeAverageType = AverageType.SIMPLE;
def shiftH = factorH * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shiftM = factorM * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);
def Avg = average[-displace];
def Upper_BandH = if KELTNER_Lines then average[-displace] + shiftH[-displace] else Double.NaN;
def Lower_BandH = if KELTNER_Lines then average[-displace] - shiftH[-displace] else Double.NaN;
def Upper_BandM = if KELTNER_Lines then average[-displace] + shiftM[-displace] else Double.NaN;
def Lower_BandM = if KELTNER_Lines then average[-displace] - shiftM[-displace] else Double.NaN;
AddCloud(if Upper_BandH < UpperBand2 and Upper_BandH < Upper_BandM then Double.NaN else Upper_BandH, UpperBand2, Color.YELLOW, Color.YELLOW);
AddCloud(if Lower_BandH > LowerBand2 then Double.NaN else Lower_BandH, LowerBand2, Color.YELLOW, Color.YELLOW);
AddCloud(if Upper_BandM < UpperBand2 then Double.NaN else Upper_BandM, UpperBand2, Color.RED, Color.RED);
AddCloud(if Lower_BandM > LowerBand2 then Double.NaN else Lower_BandM, LowerBand2, Color.RED, Color.RED);
#End Code