OPEN-SOURCE SCRIPT

smart money

//version=5
indicator("Smart Money Algorithm", overlay=true)

// Input parameters
length = input.int(20, title="Lookback Period")
volumeThreshold = input.float(1.5, title="Volume Threshold (Multiplier)")
deltaThreshold = input.float(0.7, title="Cumulative Delta Threshold")

// Calculate average volume
avgVolume = ta.sma(volume, length)

// Detect unusual volume spikes (potential smart money activity)
volumeSpike = volume > avgVolume * volumeThreshold

// Cumulative Delta (Buying/Selling Pressure)
buyVolume = volume * (close > open ? 1 : 0)
sellVolume = volume * (close < open ? 1 : 0)
cumulativeDelta = ta.cum(buyVolume - sellVolume)

// Normalize cumulative delta for visualization
normalizedDelta = cumulativeDelta / ta.highest(cumulativeDelta, length)

// Plot volume spikes
plotshape(series=volumeSpike, title="Volume Spike", location=location.belowbar, color=color.new(color.blue, 0), style=shape.labelup, text="SPIKE")

// Plot cumulative delta
deltaColor = normalizedDelta > deltaThreshold ? color.green : normalizedDelta < -deltaThreshold ? color.red : color.gray
plot(normalizedDelta, title="Cumulative Delta", color=deltaColor, linewidth=2)

// Highlight key levels (support/resistance)
supportLevel = ta.lowest(low, length)
resistanceLevel = ta.highest(high, length)

plot(supportLevel, title="Support", color=color.green, linewidth=1, style=plot.style_circles)
plot(resistanceLevel, title="Resistance", color=color.red, linewidth=1, style=plot.style_circles)

// Alerts for smart money signals
if (volumeSpike and normalizedDelta > deltaThreshold)
alert("Smart Money Buy Signal", alert.freq_once_per_bar)
if (volumeSpike and normalizedDelta < -deltaThreshold)
alert("Smart Money Sell Signal", alert.freq_once_per_bar)

Disclaimer