//@Name:Quad Average //@Description:The average of four averages related in the form x, x*2, x*4, x*8 //@Coded by Simon Griffon var period =3; function init(status) { if (status == Loading || status == Editing) { period = storage.getAt(0); colour = storage.getAt(1); pen = storage.getAt(2); width = storage.getAt(3); avgtype = storage.getAt(4); } if (status == Adding || status == Editing) { dlg = new Dialog("Quad Average Seed Average & Line Style",200,75); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",8,-1,-1,-1,"","Seed Average",period,1,100); dlg.addDropList("list1", -1,-1,-1,-1, ["Simple", "Exponential", "Weighted", "Triangular", "VariableVHF", "VariableCMO", "Vidya"], "", "Average Type"); dlg.addColLinePicker("Line1", -1, -1, -1, -1,"", "QA Line", Colour.Red); if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("INT1"); colour = dlg.getValue("line1").colour; pen = dlg.getValue("line1").pen; width = dlg.getValue("line1").width; avgtype = dlg.getValue("list1"); storage.setAt(0, period); storage.setAt(1, colour); storage.setAt(2, pen); storage.setAt(3, width); storage.setAt(4, avgtype); } setTitle("Quad Average Indicator "+period+","+period*2+","+period*4+","+period*8); setRange(Range.Parent); setSeriesColour(0, colour); setSeriesLineStyle(0,pen,width); } function getGraph(share, data) { var QA1=0; var QA2=0; var QA3=0; var QA4=0; if (avgtype == 1) { QA1 = new MA(period,MA.Exponential); QA2 = new MA(period*2,MA.Exponential); QA3 = new MA(period*4,MA.Exponential); QA4 = new MA(period*8,MA.Exponential); } if (avgtype == 2) { QA1 = new MA(period,MA.Weighted); QA2 = new MA(period*2,MA.Weighted); QA3 = new MA(period*4,MA.Weighted); QA4 = new MA(period*8,MA.Weighted); } if (avgtype == 3) { QA1 = new MA(period,MA.Triangular); QA2 = new MA(period*2,MA.Triangular); QA3 = new MA(period*4,MA.Triangular); QA4 = new MA(period*8,MA.Triangular); } if (avgtype == 4) { QA1 = new MA(period,MA.VariableVHF); QA2 = new MA(period*2,MA.VariableVHF); QA3 = new MA(period*4,MA.VariableVHF); QA4 = new MA(period*8,MA.VariableVHF); } if (avgtype == 5) { QA1 = new MA(period,MA.VariableCMO); QA2 = new MA(period*2,MA.VariableCMO); QA3 = new MA(period*4,MA.VariableCMO); QA4 = new MA(period*8,MA.VariableCMO); } if (avgtype == 6) { QA1 = new MA(period,MA.Vidya); QA2 = new MA(period*2,MA.Vidya); QA3 = new MA(period*4,MA.Vidya); QA4 = new MA(period*8,MA.Vidya); } else { QA1 = new MA(period,MA.Simple); QA2 = new MA(period*2,MA.Simple); QA3 = new MA(period*4,MA.Simple); QA4 = new MA(period*8,MA.Simple); } var main = new Array(); for (var i=0; i