//@Name:Mid % since... //@Description:Returns the mid % change over a chosen number of trading days ago //@Returns:Number //@Env:Production //@Width:60 //@Update:Intraday // 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: Richard Chiesa, ShareScript Support var period = 1; function init(status) { if (status == Loading || status == Editing) { period = storage.getAt(0); } if (status == Adding || status == Editing) { dlg = new Dialog("% change since...", 180, 55); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",8,-1,-1,-1,"","Trading Days Ago",period,0,5000); if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("INT1"); storage.setAt(0, period); } setTitle("Mid % "+period+" days"); } function getVal(share) { var mid = share.getIMid(); if (mid == undefined) var output = (share.getClose()/share.getClose(period)-1)*100; else var output = (mid/share.getClose(period)-1)*100; return output.toFixed(2); }