//@Name:Donchian Mid //@Description:A Donchian channel script with a third line representing the mid point. var period = 20 var col1 = Colour.Red var style1 = 0 var width1 = 1; var col2 = Colour.Blue var style2 = 0 var width2 = 1; function init(status) { if (status==Loading || status==Editing) { period = storage.getAt(0); col1 = storage.getAt(1); style1 = storage.getAt(2); width1 = storage.getAt(3); col2 = storage.getAt(4); style2 = storage.getAt(5); width2 = storage.getAt(6); } if (status==Adding || status==Editing) { var dlg = new Dialog((status==Adding?"Add":"Edit")+" indicator",180,60) dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",8,-1,-1,-1,"","period",period,2,1000); dlg.addColLinePicker("LN1",75,-1,-1,-1,"Donchian channel","",col1,style1,width1) dlg.addColLinePicker("LN2",75,-1,-1,-1,"Mid Line","",col2,style2,width2) if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("INT1"); col1 = dlg.getValue("LN1").colour; style1 = dlg.getValue("LN1").pen; width1 = dlg.getValue("LN1").width; col2 = dlg.getValue("LN2").colour; style2 = dlg.getValue("LN2").pen; width2 = dlg.getValue("LN2").width; storage.setAt(0, period); storage.setAt(1, col1); storage.setAt(2, style1); storage.setAt(3, width1); storage.setAt(4, col2); storage.setAt(5, style2); storage.setAt(6, width2); } setRange(Range.Parent); setSeriesColour(0, col1); setSeriesLineStyle(0, style1, width1); setSeriesColour(1, col2); setSeriesLineStyle(1, style2, width2); setSeriesColour(2, col1); setSeriesLineStyle(2, style1, width1); } function getGraph(share, data) { var band1 = new Array(data.length) var band2 = new Array(data.length) var band3 = new Array(data.length) for (var i=period;idata[j].low) ll=data[j].low; } band1[i]=hh band3[i]=ll band2[i]=(band1[i]+band3[i])/2 } return [band1,band2,band3] }