//@Name:DEMA //@Description:Double exponential moving average. // 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 periods = 21; var lineCol = Colour.Red; var lineStyle = Pen.Solid var lineWidth = 1; function init(status) { if (status==Loading || status==Editing) { periods = 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",180,40) dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",8,8,-1,-1,"","period",periods,2,1000); dlg.addColLinePicker("LN1",75,8,-1,-1,"","",lineCol,lineStyle,lineWidth) if (dlg.show()==Dialog.Cancel) return false; periods = dlg.getValue("INT1"); lineCol = dlg.getValue("LN1").colour; lineStyle = dlg.getValue("LN1").pen; lineWidth = dlg.getValue("LN1").width; storage.setAt(0, periods); storage.setAt(1, lineCol); storage.setAt(2, lineStyle); storage.setAt(3, lineWidth); } setRange(Range.Parent) setSeriesColour(0, lineCol); setSeriesLineStyle(0, lineStyle, lineWidth); setTitle(periods+" DEMA"); } function getGraph(share, data) { var ma1 = new MA(periods, MA.Exponential); var ma2 = new MA(periods, MA.Exponential); var ema1 = new Array(); var ema2 = new Array(); var dema = new Array(); //the TEMA of the close for (var i=1; i