
Author Message:
Smart Money Interest Index indicator, designed meticulously by AlgoAlpha to revolutionize the way you trade!




Read More: https://www.tradingview.com/v/oBwmJW5g/
Code:
CSS:
#// Indicator for TOS
#// © AlgoAlpha
#indicator("Smart Money Interest Index [AlgoAlpha]", "AlgoAlpha - ? Smart Money", explicit_plot_zorder = true)
# Converted by Sam4Cok@Samer800 - 04/2024
declare zerobase;
declare lower;
input colorBars = yes;
input IndexPeriod = 25; # "Index Period", minval = 1)
input VolumeFlowPeriod = 14; # "Volume Flow Period", minval = 1)
input NormalizationPeriod = 500; # "Normalization Period", minval = 1)
input HighInteresThreshold = 0.9; #, "High Interes Threshold", minval = 0.01, maxval = 0.99)
def na = Double.NaN;
def last = isNaN(close);
DefineGlobalColor("green", CreateColor(0,255,187));
DefineGlobalColor("red", CreateColor(100, 0, 0));
#// Positive Volume Index
#// the same on pine
Script f_pvi {
input src = close;
input vol = volume;
def last = isNaN(close);
def nzSrc = if(isNaN(src), 0.0, src);
def nzSrc1 = if(isNaN(src[1]), 0.0, src[1]);
def nzVol = if(isNaN(vol), 0.0, vol);
def nzVol1 = if(isNaN(vol[1]), 0.0, vol[1]);
def ta_pvi;
def prevPvi = if (if(isNaN(ta_pvi[1]), 0.0, ta_pvi[1]) == 0.0) then 1.0 else ta_pvi[1];
if nzSrc == 0.0 or nzSrc1 == 0.0 {
ta_pvi = prevPvi;
} else {
ta_pvi = if nzVol > nzVol1 then prevPvi + ((nzSrc - nzSrc1) / nzSrc1) * prevPvi else prevPvi;
}
plot f_pvi = if last then Double.NaN else if ta_pvi<=0 then 1 else ta_pvi;
}
#// Negative Volume Index
Script f_nvi {
input src = close;
input vol = volume;
def last = isNaN(close);
def nzSrc = if(isNaN(src), 0.0, src);
def nzSrc1 = if(isNaN(src[1]), 0.0, src[1]);
def nzVol = if(isNaN(vol), 0.0, vol);
def nzVol1 = if(isNaN(vol[1]), 0.0, vol[1]);
def ta_nvi;
def prevNvi = if (if(isNaN(ta_nvi[1]), 0.0, ta_nvi[1]) == 0.0) then 1.0 else ta_nvi[1];
if nzSrc == 0.0 or nzSrc1 == 0.0 {
ta_nvi = prevNvi;
} else {
ta_nvi = if nzVol < nzVol1 then prevNvi + ((nzSrc - nzSrc1) / nzSrc1) * prevNvi else prevNvi;
}
plot f_nvi = if last then Double.NaN else if ta_nvi <=0 then 1 else ta_nvi;
}
def pvi = f_pvi();
def nvi = f_nvi();
def dumb = pvi - ExpAverage(pvi, 255);
def smart = nvi - ExpAverage(nvi, 255);
def drsi = rsi(Price = dumb, Length = VolumeFlowPeriod);
def srsi = rsi(Price = smart, Length = VolumeFlowPeriod);
#//ratio shows if smart money is buying from dumb money selling and vice versa
def r = srsi / drsi;
def sums = sum(r, IndexPeriod);
def peak = highest(sums, NormalizationPeriod);
def index = sums / peak;
def bottom = if last then na else 0;
def top = if last then na else Double.POSITIVE_INFINITY;
def thresh = if last then na else HighInteresThreshold;
def SMII = index; # Smart Money Interest Index
def lvl1 = thresh * 3/4;
def lvl2 = thresh / 2;
def lvl3 = thresh / 4;
#-- Cloud and bar color
AddCloud(top, thresh, Color.DARK_ORANGE, Color.DARK_ORANGE, yes);
AddCloud(thresh, SMII, GlobalColor("red")); #, GlobalColor("red"), yes);
AddCloud(lvl1, SMII, GlobalColor("red"));#, GlobalColor("red"), yes);
AddCloud(lvl2, SMII, GlobalColor("red")); #, GlobalColor("red"), yes);
AddCloud(lvl3, SMII, GlobalColor("red")); #, GlobalColor("red"), yes);
AddCloud(SMII, bottom, GlobalColor("green"), GlobalColor("green"), yes);
AssignPriceColor(if !colorBars then Color.CURRENT else if SMII > thresh then Color.CYAN else Color.CURRENT);
#-- END of CODE
Last edited by a moderator: