//@Name:Dividend Discount Model //@Description:Returns the intrinsic value of a stock based on the Dividend Discount Model. The script calculates the annualised growth rate of the dividends between 2 yrs ago and the 3 yr f/c figure. It then uses this to calculate f/c dividend figures for 20 years. The formula used is DIV1/r^1 + DIV2/r^2 +...+DIVn/r^n where r is the required rate of return. //@Returns:Number //@Width:80 //@Env:Production //More information about the DDM calculation can be read here: http://www.investopedia.com/articles/basics/12/intrinsic-value.asp var RRR= 5 //Required Rate of Return function init(status) { if (status == Loading || status == Editing) { RRR = storage.getAt(0); } if (status == Adding || status == Editing) { dlg = new Dialog("Settings...",240,60); dlg.addOkButton(); dlg.addCancelButton(); dlg.addNumEdit("VAL1",85,5,-1,-1,"Required Rate of Return","",RRR) if (dlg.show()==Dialog.Cancel) return false; RRR = dlg.getValue("VAL1"); storage.setAt(0, RRR); } //sets the title of the column setTitle("DDM: RRoR = "+RRR+"%"); } function getVal(share) { var VOS = 0; var div0 = share.getResult(3,Result.Dividend); var div1 = share.getResult(-2,Result.Dividend); if (div0 == null || div1== null || div0 == 0 || div1 == 0) return; var annGr = Math.pow(div0/div1,1/5); var prevDiv; for (var i = 1;i<=20;i++) { div = share.getResult(i,Result.Dividend); if (div==undefined) { div = prevDiv*annGr; } VOS += (div / Math.pow(1+RRR/100,i)) prevDiv = div; } return VOS.toFixed(2); }