//@Name:EPS %WMA //@Description:Weighted MA of the last 5 results & up to 3 forecast years of EPS growth //@Returns:Number //@Width:50 // Gives a lower weighting to older growth and to forecast growth. // Make maximum growth rate 100%. // return blank if any EPS values are negative i.e. the company made a loss // weighting for each results 1, 2, 3, 4, 5 then for the forecasts 3, 2 and 1 function init() { } function getVal(share) { var year,i; var x=0; // running total var y=0; // divisor var epsPrev=undefined; for(i=0,year=-5;year<=3;year++) { var eps=share.getResult(year,Result.EPS); if (eps<0) return undefined; // want all historic results show profits if (eps!=undefined && epsPrev!=undefined) { var growth; if (epsPrev>0) // avoid divide by zero growth=eps/epsPrev-1; if (growth>1) growth=1; x+=i*growth; y+=i; } epsPrev=eps if (year<0) i++; else if (year==0) i-=2; // first year of forecast else i--; } return 100*x/y; // return % weighted average EPS growth }