//@LibraryID:9,0 //@Name:Hull MA //@Description:16 Period Hull MA (Main graph indicator) // The Hull MA cuts out some lag at the price of occasionally overshooting // See www.alanhull.com.au for more detail // 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. var period = 16; var lineCol = Colour.Red; var lineStyle = 0; var lineWidth = 1; function init(status) { if (status==Loading || status==Editing) { period = storage.getAt(0); lineCol = storage.getAt(1); lineStyle = storage.getAt(2); lineWidth = storage.getAt(3); } if (status==Adding || status==Editing) { var dlg = new Dialog((status==Adding?"Add":"Edit")+" indicator",150,50) dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",8,-1,-1,-1,"","Period",period,2,10000); dlg.addColLinePicker("LN1",8,-1,-1,-1,"","",lineCol,lineStyle,lineWidth) if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("INT1"); lineCol = dlg.getValue("LN1").colour; lineStyle = dlg.getValue("LN1").pen; lineWidth = dlg.getValue("LN1").width; storage.setAt(0, period); storage.setAt(1, lineCol); storage.setAt(2, lineStyle); storage.setAt(3, lineWidth); } setSeriesColour(0, lineCol); setSeriesLineStyle(0, lineStyle, lineWidth); setRange(Range.Parent); } function getGraph(share, data) { var sqrtperiod = Math.round(Math.sqrt(period)); var output = new Array(); var ma1 = new MA(Math.round(period/2), MA.Weighted); var ma2 = new MA(period, MA.Weighted); var ma3 = new MA(sqrtperiod, MA.Weighted); for (var i=0; i