//@Name:Lowest Values //@Description:Returns the lowest EPS or PE result over a chosen number of years //@Returns:Number //@Width:60 //@Env:Production var years = 10; var list = ["EPS","PE"]; var listChoice = 0; var negPE = 0; function init(status) { if (status == Loading || status == Editing) { years = storage.getAt(0); listChoice = storage.getAt(1); negPE = storage.getAt(2); } if (status == Adding || status == Editing) { dlg = new Dialog("Lowest values...", 180, 78); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",40,8,-1,-1,"lookback:","years",years,0,10); dlg.addDropList("VAL",40,25,50,-1,list,"lowest:","",listChoice); dlg.addGroupBox(5,45,105,25,"PE ratios"); dlg.addTickBox("T1",10,56,95,-1,"Ignore negative PE ratios",negPE); if (dlg.show()==Dialog.Cancel) return false; years = dlg.getValue("INT1"); listChoice = dlg.getValue("VAL"); negPE = dlg.getValue("T1"); storage.setAt(0, years); storage.setAt(1, listChoice); storage.setAt(2, negPE); } if (listChoice==1 && negPE == 1) { setTitle("lowest "+list[listChoice]+" (ignore negs)"); } else { setTitle("lowest "+list[listChoice]); } } function getVal(share) { var minCalc = new MinMax(years); for (var i=0;i