# Enhanced Bollinger Bands Squeeze Indicator with Volume Confirmation
# Input parameters
input length = 20;
input numDevDn = -2.0;
input numDevUp = 2.0;
input volumeMultiplier = 1.5;
input rsiLength = 14;
input rsiOverbought = 70;
input rsiOversold = 30;
# Calculate Bollinger Bands
def price = close;
def sma = SimpleMovingAvg(price, length);
def sd = StDev(price, length);
def lowerBand = sma - numDevDn * sd;
def upperBand = sma + numDevUp * sd;
# Calculate Bollinger Bands Width
def bbWidth = (upperBand - lowerBand) / sma;
# Calculate Volume Multiplier
def averageVolume = Average(volume, length);
def volumeCondition = volume > averageVolume * volumeMultiplier;
# Calculate RSI
def rsi = RSI(close, rsiLength);
# Calculate Moving Averages
def shortMA = SimpleMovingAvg(close, 10);
def longMA = SimpleMovingAvg(close, 50);
# Plot Bollinger Bands Squeeze Signal
plot squeezeSignal = if bbWidth <= Lowest(bbWidth, length) and volumeCondition then 1 else 0;
squeezeSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
squeezeSignal.SetLineWeight(2);
squeezeSignal.AssignValueColor(if close > close[1] then Color.GREEN else Color.RED);
# Plot RSI conditions
plot overboughtSignal = if rsi > rsiOverbought then 1 else 0;
plot oversoldSignal = if rsi < rsiOversold then 1 else 0;
overboughtSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
oversoldSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
overboughtSignal.SetLineWeight(2);
oversoldSignal.SetLineWeight(2);
overboughtSignal.AssignValueColor(Color.RED);
oversoldSignal.AssignValueColor(Color.GREEN);
# Plot Moving Average Crossover
def trendSignal = if shortMA > longMA and shortMA[1] <= longMA[1] then 1 else if shortMA < longMA and shortMA[1] >= longMA[1] then -1 else 0;
plot trendArrow = if trendSignal == 1 then low - 2 else if trendSignal == -1 then high + 2 else double.nan;
trendArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
trendArrow.SetLineWeight(2);
trendArrow.AssignValueColor(Color.YELLOW);
# Highlight Bollinger Bands on the chart
plot bbUpper = upperBand;
plot bbLower = lowerBand;
bbUpper.SetDefaultColor(Color.GRAY);
bbLower.SetDefaultColor(Color.GRAY);
# Add labels
AddLabel(yes, "Enhanced Bollinger Bands Squeeze with Volume, RSI, and MA Confirmation", Color.CYAN);
AddLabel(yes, "Squeeze Signal: Green arrow indicates potential breakout", Color.YELLOW);
AddLabel(yes, "RSI Overbought: Red arrow indicates potential overbought condition", Color.RED);
AddLabel(yes, "RSI Oversold: Green arrow indicates potential oversold condition", Color.GREEN);
AddLabel(yes, "MA Crossover: Yellow arrow indicates short-term trend change", Color.YELLOW);
# Input parameters
input length = 20;
input numDevDn = -2.0;
input numDevUp = 2.0;
input volumeMultiplier = 1.5;
input rsiLength = 14;
input rsiOverbought = 70;
input rsiOversold = 30;
# Calculate Bollinger Bands
def price = close;
def sma = SimpleMovingAvg(price, length);
def sd = StDev(price, length);
def lowerBand = sma - numDevDn * sd;
def upperBand = sma + numDevUp * sd;
# Calculate Bollinger Bands Width
def bbWidth = (upperBand - lowerBand) / sma;
# Calculate Volume Multiplier
def averageVolume = Average(volume, length);
def volumeCondition = volume > averageVolume * volumeMultiplier;
# Calculate RSI
def rsi = RSI(close, rsiLength);
# Calculate Moving Averages
def shortMA = SimpleMovingAvg(close, 10);
def longMA = SimpleMovingAvg(close, 50);
# Plot Bollinger Bands Squeeze Signal
plot squeezeSignal = if bbWidth <= Lowest(bbWidth, length) and volumeCondition then 1 else 0;
squeezeSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
squeezeSignal.SetLineWeight(2);
squeezeSignal.AssignValueColor(if close > close[1] then Color.GREEN else Color.RED);
# Plot RSI conditions
plot overboughtSignal = if rsi > rsiOverbought then 1 else 0;
plot oversoldSignal = if rsi < rsiOversold then 1 else 0;
overboughtSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
oversoldSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
overboughtSignal.SetLineWeight(2);
oversoldSignal.SetLineWeight(2);
overboughtSignal.AssignValueColor(Color.RED);
oversoldSignal.AssignValueColor(Color.GREEN);
# Plot Moving Average Crossover
def trendSignal = if shortMA > longMA and shortMA[1] <= longMA[1] then 1 else if shortMA < longMA and shortMA[1] >= longMA[1] then -1 else 0;
plot trendArrow = if trendSignal == 1 then low - 2 else if trendSignal == -1 then high + 2 else double.nan;
trendArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
trendArrow.SetLineWeight(2);
trendArrow.AssignValueColor(Color.YELLOW);
# Highlight Bollinger Bands on the chart
plot bbUpper = upperBand;
plot bbLower = lowerBand;
bbUpper.SetDefaultColor(Color.GRAY);
bbLower.SetDefaultColor(Color.GRAY);
# Add labels
AddLabel(yes, "Enhanced Bollinger Bands Squeeze with Volume, RSI, and MA Confirmation", Color.CYAN);
AddLabel(yes, "Squeeze Signal: Green arrow indicates potential breakout", Color.YELLOW);
AddLabel(yes, "RSI Overbought: Red arrow indicates potential overbought condition", Color.RED);
AddLabel(yes, "RSI Oversold: Green arrow indicates potential oversold condition", Color.GREEN);
AddLabel(yes, "MA Crossover: Yellow arrow indicates short-term trend change", Color.YELLOW);