//@Name:NAV Indicator //@Description:An indicator that plots the share's end of year NAV. var colour1 = 255; var pen1 = 0; var width1 = 0; var option = 0; var optionList = ["Plot NAV","Plot NAV per Share"]; function init(status) { if (status == Loading || status == Editing) { colour1 = storage.getAt(0); pen1 = storage.getAt(1); width1 = storage.getAt(2); option = storage.getAt(3); } if (status == Adding || status == Editing) { dlg = new Dialog("NAV Line Settings",175,50); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("VAL2",5,5,80,-1,optionList,"","",option); dlg.addColLinePicker("VAL1",5,22,-1,-1,"","",colour1,pen1,width1); if (dlg.show()==Dialog.Cancel) return false; colour1 = dlg.getValue("VAL1").colour; pen1 = dlg.getValue("VAL1").pen; width1 = dlg.getValue("VAL1").width; option = dlg.getValue("VAL2"); storage.setAt(0, colour1); storage.setAt(1, pen1); storage.setAt(2, width1); storage.setAt(3, option); } setSeriesColour(0,colour1); setSeriesLineStyle(0,pen1,width1); } function getGraph(share, data) { var output = new Array(); var NAV = 0; var NAVYear = 0; for (var i=data.length-1; i>=0; i--) { if (data[i].date < share.getResult(NAVYear, Result.Date)) NAVYear--; option==0?NAV = share.getResult(NAVYear, Result.BookValue):NAV = share.getResult(NAVYear, Result.BookValuePS); if (NAV>=0) output[i] = NAV else output[i] = 0; } return output; }