// Downloaded From https://www.WiseStockTrader.com
MaxVol=2*EMA(V,50);
Adjustment=V-(V-MaxVol);
Value=IIf(V>MaxVol,Adjustment,IIf(V<MaxVol,V,V));
Up=IIf(C>Ref(C,-1),(C-Ref(C,-1))*Value,(C-Ref(C,-1))*Value);
Down=IIf(C<Ref(C,-1),(Ref(C,-1)-C)*Value,(Ref(C,-1)-C)*Value);

S=EMA(Sum(up,21)-Sum(down,21),3);

Plot( S, "Sentiment Index", ParamColor( "SI Color", colorBlue), ParamStyle("SI Style", styleHistogram | styleThick));

Plot(0,"",ParamColor("ZeroColor", colorRed),styleLine);