//@Name:Average Spread //@Description:Returns the shares average spread over a chosen period //@Type: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 = 10; function init(status) { if (status == Loading || status == Editing) { period = storage.getAt(0); } if (status == Adding || status == Editing) { dlg = new Dialog("Select MA period", 145, 55); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",8,-1,-1,-1,"","MA period",period,2,1000); if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("INT1"); storage.setAt(0, period); } setSeriesColour(0, Colour.Red); } function getGraph(share, data) { setTitle(period+" SMA of Spread %"); var output = new Array(); if (data.length<2) return returnNothing(data.length); var bidOffer = []; for (var i=2;i>=0;i--) bidOffer = bidOffer.concat(share.getIBidOfferArray(i)); for (var i=0;i0) output[i] = output[i-1]; } return output; } function returnNothing(n) { var output = []; for (var i=0;i