#This study color codes volume by amount of volume on up-tick versus amount of volume on down-tick #It provides it's own volume bars and mixes the green for buy and red as overlays so you'd probably want it in it's own lower window on a TOS chart. #It also provides labels in the window showing 1 bar buy and sell volume, ie. green and red labels. Also shows the cumulative volume over a number of bars you set, default is 10 bars. Shows this volume as two lables, again buy and sell volume. #Finally it shows a label that reflects then percentage of buying volume versus selling volume over then afformentioned cumulative numbers of bars that you set.above again default is 10 bars. #BE AWARE that TOS data feeds do not provide the time and sales in a streaming mode, instead they send it to TOS via a block transfer mechanism so these values are not exact as I would normally get the time and sales trades and associate the trades at current ask price as 'buys' and trades at current bid price as 'sells'. Best that I (at least) can do with TOS. declare lower; input ShowBuyingVolume = yes; input ShowSellingVolume = yes; input ShowCumulativeBars = yes; input CumulativeBars = 10; input BullThreshold = 55; input BearThreshold = 45; def O = open; def H = high; def C = close; def L = low; def V = volume; def isBuyNan = (C-L)/(H-L); def isSellNan = (H-C)/(H-L); #def Buying = if (!isBuyNan, V*(C-L)/(H-L),Buying[1]); #def Buying = V*(C-L)/(H-L); def Buying = if (isNan(isBuyNan), Buying[1],Round(V*(C-L)/(H-L))); def Selling = if (isNan(isSellNan), Selling[1],Round( V*(H-C)/(H-L))); # Selling Volume Plot SellVol = Selling; SV.setPaintingStrategy(PaintingStrategy.Histogram); SV.SetDefaultColor(Color.downtick); SV.HideTitle(); SV.HideBubble(); SV.SetLineWeight(4); # Buying Volume # Note that Selling + Buying Volume will equal Volume. Plot BuyVol = Buying; BV.setPaintingStrategy(PaintingStrategy.Histogram); BV.SetDefaultColor(Color.uptick); BV.HideTitle(); BV.HideBubble(); BV.SetLineWeight(4); AddLabel(ShowBuyingVolume, "Est Vol: "+ Round(Buying,0), Color.uptick); AddLabel(ShowSellingVolume, "Est Vol: "+ Round(Selling,0), Color.downtick); #spacer AddLabel(ShowSellingVolume, " ", Color.black); AddLabel(ShowCumulativeBars, "Est " + CumulativeBars + " Bar Vol: "+ Round(Sum(Buying,CumulativeBars),0), Color.uptick); AddLabel(ShowCumulativeBars, "Est " + CumulativeBars + " Bar Vol: "+ Round(Sum(Selling,CumulativeBars),0), Color.downtick); #spacer AddLabel(ShowSellingVolume, " ", Color.black); AddLabel(yes, "Est " + CumulativeBars + " Bar Buy Ratio " + Round((Round(Sum(Buying,CumulativeBars),0)* 100) /(Round(Sum(Selling,CumulativeBars),0) + Round(Sum(Buying,CumulativeBars),0)),0) + "%", (if Round((Round(Sum(Buying,CumulativeBars),0)* 100) /(Round(Sum(Selling,CumulativeBars),0) + Round(Sum(Buying,CumulativeBars),0)),0) <= BearThreshold then Color.violet else if Round((Round(Sum(Buying,CumulativeBars),0)* 100) /(Round(Sum(Selling,CumulativeBars),0) + Round(Sum(Buying,CumulativeBars),0)),0) >= BullThreshold then Color.green else Color.Yellow));