OPEN-SOURCE SCRIPT
Updated

Advanced Chart Pattern and Liquidity Indicator

//version=5
indicator("Advanced Chart Pattern and Liquidity Indicator", overlay=true)

// Inputs for customization
showChartPatterns = input.bool(true, title="Show Chart Patterns")
showCandlePatterns = input.bool(true, title="Show Candlestick Patterns")
showSupportResistance = input.bool(true, title="Show Support/Resistance Zones")
showBuySellZones = input.bool(true, title="Show Buy/Sell Zones")
showLiquidity = input.bool(true, title="Show Liquidity Levels")

// Chart Pattern Detection
f_detectChartPatterns() =>
leftShoulder = high[2] > high[1] and high[2] > high[3]
head = high[1] > high[2] and high[1] > high[0]
rightShoulder = high[0] > high[1] and high[0] > high[-1]
neckline = low[1] < low[2] and low[1] < low[0]
headAndShoulders = leftShoulder and head and rightShoulder and neckline
headAndShoulders

// Candlestick Pattern Detection
f_detectCandlePatterns() =>
bullishEngulfing = close[1] < open[1] and close > open and close > open[1] and open < close[1]
bearishEngulfing = close[1] > open[1] and close < open and close < open[1] and open > close[1]
[bullishEngulfing, bearishEngulfing]

// Support and Resistance Zones
f_calculateSupportResistance() =>
support = ta.lowest(low, 20)
resistance = ta.highest(high, 20)
[support, resistance]

// Buy/Sell Zones
f_identifyBuySellZones() =>
rsi = ta.rsi(close, 14)
ma = ta.sma(close, 20)
buyZone = rsi < 30 and close > ma
sellZone = rsi > 70 and close < ma
[buyZone, sellZone]

// Liquidity Levels
f_detectLiquidity() =>
vwap = ta.vwap(close)
liquidityHigh = vwap + ta.stdev(close, 20)
liquidityLow = vwap - ta.stdev(close, 20)
[liquidityHigh, liquidityLow]

// Compute Values Outside of `if` Scope
chartPattern = showChartPatterns and f_detectChartPatterns() ? 1 : na
[bullishEngulfing, bearishEngulfing] = f_detectCandlePatterns()
[support, resistance] = f_calculateSupportResistance()
[buyZone, sellZone] = f_identifyBuySellZones()
[liquidityHigh, liquidityLow] = f_detectLiquidity()

// Plot Values Outside of `if` Scope
plotshape(chartPattern, title="Head and Shoulders", location=location.abovebar, color=color.blue, style=shape.labeldown)
plotshape(showCandlePatterns and bullishEngulfing ? 1 : na, title="Bullish Engulfing", location=location.belowbar, color=color.green, style=shape.labelup)
plotshape(showCandlePatterns and bearishEngulfing ? 1 : na, title="Bearish Engulfing", location=location.abovebar, color=color.red, style=shape.labeldown)
plot(showSupportResistance ? support : na, title="Support Zone", color=color.green, linewidth=2)
plot(showSupportResistance ? resistance : na, title="Resistance Zone", color=color.red, linewidth=2)
plotshape(showBuySellZones and buyZone ? 1 : na, title="Buy Zone", location=location.belowbar, color=color.green, style=shape.labelup)
plotshape(showBuySellZones and sellZone ? 1 : na, title="Sell Zone", location=location.abovebar, color=color.red, style=shape.labeldown)
plot(showLiquidity ? liquidityHigh : na, title="Liquidity High", color=color.blue, linewidth=2)
plot(showLiquidity ? liquidityLow : na, title="Liquidity Low", color=color.orange, linewidth=2)
Release Notes
update

Disclaimer