//@Name:OBV % Change //@Description: Displays the percentage change between two values of the OBV indicator. Not calculated for negative indicator values. //@Returns:Number //@Width:90 //@Env:Production //@Update:Periodic,60 // 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. // Coded by: Phil Tolhurst, ShareScope Support // Modified by: Paul Hall, ShareScope Support var dataType = 0; var dataList = ["Daily","Weekly","Monthly"]; var lookback = 10; function init(status) { if (status == Loading || status == Editing) { dataType = storage.getAt(0); lookback = storage.getAt(1); } if (status == Adding || status == Editing) { var dlg = new Dialog("OBV Slope Settings", 205, 45); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("VAL1",55,-1,-1,-1, dataList,"Date Source:","",dataType); dlg.addIntEdit("INT1",8,-1,-1,-1,"","lookback period",lookback,1,1000); if (dlg.show() == Dialog.Ok) { dataType=dlg.getValue("VAL1"); lookback=dlg.getValue("INT1"); storage.setAt(0, dataType); storage.setAt(1, lookback); } else { return false; } } setTitle(" OBV("+dataList[dataType]+") %change over "+lookback+" td") } function getVal(share) { if (dataType == 0) var data = share.getPriceArray(); if (dataType == 1) var data = share.getWeeklyBarArray(); if (dataType == 2) var data = share.getMonthlyBarArray(); var output = 0; var OBVres=new Array(); var OBVcalc = new OnBalVol(); for (var i=0;i 0 && OBVres[y] > 0) { output = ((OBVres[t]-OBVres[y])/OBVres[y]*100); } else return; return output.toFixed(2); }