Code: Select all
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlgoAlpha
//@version=6
indicator("Smart Money Volume Index [AlgoAlpha]", "AlgoAlpha - Smart Money", explicit_plot_zorder = true, behind_chart=false)
mode = input.string("Net", "Display Mode", options = ["Compare", "Net"], group = "Settings", tooltip = "Choose between 'Compare' to see buy/sell interest separately, or 'Net' for a single oscillator.")
x = input.int(25, "Index Period", minval = 1, group = "Settings", tooltip = "Length of the summation period for the interest index.")
rr = input.int(14, "Volume Flow Period", minval = 1, group = "Settings", tooltip = "RSI period applied to the volume flow calculations.")
peakslen = input.int(500, "Normalization Period", minval = 1, group = "Settings", tooltip = "Lookback period for finding the peak value to normalize the index.")
thr = input.float(0.9, "High Interest Threshold", minval = 0.01, maxval = 0.99, step = 0.05, group = "Settings", tooltip = "Level at which interest is considered 'High'. Triggers alerts and highlights.")
green = input.color(#00ffbb, "Up Color", group = "Colors", tooltip = "Main color for Buying Interest.")
sec_green = input.color(#008461, "Secondary Up Color", group = "Colors", tooltip = "Secondary color for Net Buy layers.")
red = input.color(#ff1100, "Down Color", group = "Colors", tooltip = "Main color for Selling Interest.")
sec_red = input.color(#840900, "Secondary Down Color", group = "Colors", tooltip = "Secondary color for Net Sell layers.")
dumb = ta.pvi-ta.ema(ta.pvi,255)
smart = ta.nvi-ta.ema(ta.nvi,255)
drsi = ta.rsi(dumb, rr)
srsi = ta.rsi(smart, rr)
r_buy = srsi / drsi //ratio shows if smart money is buying from dumb money selling
r_sell = (100 - srsi) / (100 - drsi) //ratio shows if dumb money is buying from smart money selling
sums_buy = math.sum(r_buy, x)
sums_sell = math.sum(r_sell, x)
peak = ta.highest(math.max(sums_buy, sums_sell), peakslen)
index_buy = sums_buy / peak
index_sell = sums_sell / peak
net_index = index_buy - index_sell
bottom = plot(0, "Zero Line", color = color.gray)
top = plot(1, "Top Limit", display = display.none)
low_ = plot(-1, "Bottom Limit", display = display.none)
thresh_up = plot(thr, "High Buy Threshold", display = display.none)
thresh_down = plot(-thr, "High Sell Threshold", display = display.none)
plot_buy = mode == "Compare" ? index_buy : na
plot_sell = mode == "Compare" ? -index_sell : na
i_buy = plot(plot_buy, "Buy Interest", color = green, style = plot.style_linebr)
i_sell = plot(plot_sell, "Sell Interest", color = red, style = plot.style_linebr)
// Net Mode Layered Columns
transp = 20
n_up = mode == "Net" and net_index > 0 ? net_index : na
n_dn = mode == "Net" and net_index < 0 ? net_index : na
plot(n_up, "Net Buy 100", color = color.new(sec_green, transp + 60), style = plot.style_columns, linewidth = 4)
plot(n_up * 0.8, "Net Buy 80", color = color.new(sec_green, transp + 55), style = plot.style_columns, linewidth = 4)
plot(n_up * 0.6, "Net Buy 60", color = color.new(sec_green, transp + 45), style = plot.style_columns, linewidth = 4)
plot(n_up * 0.4, "Net Buy 40", color = color.new(sec_green, transp + 30), style = plot.style_columns, linewidth = 4)
plot(n_up * 0.2, "Net Buy 20", color = color.new(sec_green, transp + 25), style = plot.style_columns, linewidth = 4)
plot(n_up, "Net Buy Line", color = color.new(green, transp), style = plot.style_linebr)
plot(n_dn, "Net Sell 100", color = color.new(sec_red, transp + 60), style = plot.style_columns, linewidth = 4)
plot(n_dn * 0.8, "Net Sell 80", color = color.new(sec_red, transp + 55), style = plot.style_columns, linewidth = 4)
plot(n_dn * 0.6, "Net Sell 60", color = color.new(sec_red, transp + 45), style = plot.style_columns, linewidth = 4)
plot(n_dn * 0.4, "Net Sell 40", color = color.new(sec_red, transp + 30), style = plot.style_columns, linewidth = 4)
plot(n_dn * 0.2, "Net Sell 20", color = color.new(sec_red, transp + 25), style = plot.style_columns, linewidth = 4)
plot(n_dn, "Net Sell Line", color = color.new(red, transp), style = plot.style_linebr)
v_up = mode == "Compare" ? index_buy : net_index
v_dn = mode == "Compare" ? -index_sell : net_index
top_active = v_up > 0.7
bot_active = v_dn < -0.7
fill(thresh_up, top, 1, thr, top_active ? color.new(chart.fg_color, 45) : color.new(chart.fg_color, 90), top_active ? color.new(chart.fg_color, 30) : color.new(chart.fg_color, 60))
fill(thresh_down, low_, -thr, -1, bot_active ? color.new(chart.fg_color, 30) : color.new(chart.fg_color, 60), bot_active ? color.new(chart.fg_color, 45) : color.new(chart.fg_color, 90))
fill(bottom, i_buy, plot_buy, 0, green, chart.bg_color)
fill(bottom, i_sell, plot_sell, 0, red, chart.bg_color)
sig_buy = mode == "Compare" ? index_buy : net_index
sig_sell = mode == "Compare" ? index_sell : -net_index
abs_net = math.abs(net_index)
net_color = net_index > 0 ? color.from_gradient(abs_net, 0, 1, chart.bg_color, green) : color.from_gradient(abs_net, 0, 1, chart.bg_color, red)
comp_color = sig_buy > thr ? green : sig_sell > thr ? red : na
candle_color = mode == "Net" ? net_color : comp_color
plotcandle(open, high, low, close, "Smart Money Candles", color = candle_color, wickcolor = candle_color, bordercolor = candle_color, force_overlay = true)
plot(close, "Price Tracking line", color = color.new(chart.fg_color, 85), force_overlay = true)
///Alerts
alertcondition(ta.crossover(sig_buy, thr), "High Smart Money Buy Interest")
alertcondition(ta.crossover(sig_sell, thr), "High Smart Money Sell Interest")
alertcondition(ta.crossunder(sig_buy, thr), "Smart Money Buy Interest no longer high")
alertcondition(ta.crossunder(sig_sell, thr), "Smart Money Sell Interest no longer high")
alertcondition(ta.crossover(sig_buy, 0), "Smart Money Buy Interest turned positive")
alertcondition(ta.crossunder(sig_buy, 0), "Smart Money Buy Interest turned negative")
alertcondition(ta.crossover(sig_sell, 0), "Smart Money Sell Interest turned positive")
alertcondition(ta.crossunder(sig_sell, 0), "Smart Money Sell Interest turned negative")
alertcondition(ta.crossover(v_up, 0.7), "Smart Money Buy Interest entered high zone")
alertcondition(ta.crossunder(v_up, 0.7), "Smart Money Buy Interest exited high zone")
I given Completely...
I wish you can found the Benefits from this Script.