Блог им. VinniPuh_3af
//@version=4 study(title="RedK_Supply/Demand Volume Viewer v1", shorttitle="VViewer1", format=format.volume) //inputs l=input(10, title="Volume Length") s=input(3, title="Smoothing") //calculations red = #d5180b, green = #007f0e, upday = close > open v=volume Body = abs(close - open) BarRange = high - low Wick = (BarRange - Body) RealBarRange = BarRange + Wick //Calc supply & Demand per Bar .. beware of the odd case of 0 price movement during bar.. assigne equal share to bulls & bears BScore = BarRange > 0 ? (close >= open ? BarRange / RealBarRange : Wick / RealBarRange) : 0.5 BullScore = BScore * v, demand = wma(BullScore,l) BearScore = v - BullScore, supply = wma(BearScore,l) NetVol = demand - supply NetVol_s = wma(NetVol, s) //Plot Section hline(0, title="zero line", color = color.white, linestyle = hline.style_solid, editable = false) plot(v, title='Volume', color= upday? green : red, style=plot.style_columns, transp=70, display = 0 ) plot(supply, title='Supply', color=color.red, style=plot.style_line, transp=20, linewidth=2, display = 0 ) plot(demand, title='Demand', color=color.green, style=plot.style_line, transp=20, linewidth=2, display = 0 ) // Net Volume Plot plot(NetVol_s, title='Volume Viewer',style=plot.style_area , color = NetVol_s >= 0 ? green : red) plot(NetVol_s, title='Volume Viewer Line',style=plot.style_line , color = color.white, linewidth=1)