//@LibraryID:789,0 //@Name:Vol Profile Pos/Neg //@Description:Volume Profile Histogram, with separate colours for poitive and negative volume // Author: Richard Chiesa, ShareScript Support // Care has been taken in preparing this code but it is provided without guarantee. // You are welcome to modify and extend it. Please add your name as a modifier if you distribute it. var volBarNum = 20; var volBarPosCol = Colour.RGB(90,0,0); var volBarNegCol = Colour.RGB(0,0,90); var textCol = 16711935; var showValues = false; function init(status) { storage.setAt(0, volBarNum); storage.setAt(1, volBarPosCol); storage.setAt(2, volBarNegCol); storage.setAt(3, textCol); storage.setAt(4, showValues); createButton("Settings...", settingsFn); } function onNewChart() { onZoom(); } function onZoom() { setLayer(Layer.Bottom); setFillMode(FillMode.Transparent); clearDisplay(); var s = getMinVisibleBarIndex(); var f = getMaxVisibleBarIndex(); var hh, ll; // high and low of the period var posVolBar = []; //array of positive volume bars var negVolBar = []; //array of negative volume bars for (var i=0;ihh) hh = bars[i].close; if (ll == null || bars[i].close= ll + (volBarRange*j)) && (bars[i].close <= ll + (volBarRange*(j+1)))) { if (i>0 && bars[i].closemaxVolBar) maxVolBar = posVolBar[i]+negVolBar[i]; totVol += posVolBar[i]+negVolBar[i]; } var volPerIndex = maxVolBar / (f-s); setFontColour(textCol); for (i=0;i