//@Name:Intra Vol as Percent of ADV //@Description:Returns the Intraday Volume as a percentage of the ADV //@Returns:Number //@Width:70 //@Update:Intraday //Coded by: Phil Tolhurst, 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 period = 25; var maTitleList = ["SMA","EMA","WMA","TMA","VVHF","VCMO","VIDYA"] var maList = ["Simple","Exponential","Weighted","Triangular","VariableVHF","VariableCMO","VIDYA"] var maType = 0; function init(status) { if (status == Loading || status == Editing) { period = storage.getAt(0); maType = storage.getAt(1); } if (status == Adding || status == Editing) { dlg = new Dialog("Volume Vs ADV",150,50); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("VAL1",8,8,-1,-1,""," MA period",period,2,1000); dlg.addDropList("VAL2",8,23,-1,-1,maList,"","",maType); if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("VAL1"); maType = dlg.getValue("VAL2"); storage.setAt(0, period); storage.setAt(1,maType); } setTitle("Intra Vol as % of ADV ("+period+" "+maTitleList[maType]+")"); } function getVal(share) { var data = share.getPriceArray(); var advCalc = new MA(period,maType); var advResult = 0; var pcntVal = 0; var idata = share.getIBarArray(0,86400); if (idata==undefined || idata.length!=1 || new Date().getDate()!=idata[0].date.getDate()) return; var iVolume = idata[0].volume if (data==undefined || data.length<2) return; //if (data[data.length-(period+1)].volume == undefined) return; for (var i=0;i