//@Name:SQN indicator //@Description:average percentage change/std deviation. //Author:Richard Chiesa, ShareScript Support //Modified by:Paul Hall, ShareScope Support // 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 dataList = ["Daily","Weekly","Monthly"]; var dataList2 = ["Days","Weeks","Months"] var dataType =0; var period = 100; var lineCol = Colour.RGB(255,190,0); var lineStyle = Pen.Solid; 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); dataType = storage.getAt(4); } if (status == Adding || status == Editing) { var dlg = new Dialog("SQN indicator",160,60); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("VAL", 8,-1,-1,-1,dataList) dlg.addNumEdit("INT1",8,-1,-1,-1,"","Periods",period,2,1000); 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; dataType = dlg.getValue("VAL"); storage.setAt(0, period); storage.setAt(1, lineCol); storage.setAt(2, lineStyle); storage.setAt(3, lineWidth); storage.setAt(4, dataType); } setTitle("SQN indicator ("+period+" "+dataList2[dataType]+")"); setSeriesLineStyle(0, lineStyle, lineWidth); setSeriesColour(0, lineCol); setHorizontalLine(0); } function getGraph(share, data) { var ma1 = new MA(period, 0); //type of MA var v1 = new Array(); var av1 = new Array(); var y1 = new Array(); var SQN = new Array(); for (var i=period;i