//@Name:Aroon Oscillator //@Description:An Aroon Oscillator (Aroon Up - Aroon Down) with editable horizontal lines //Author: 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 period = 20; var topValue = 50; var topBox = 1; var midValue = 0; var midBox = 1; var botValue = -50; var botBox = 1; var upCol = Colour.DarkBlue; var upPen = Pen.Solid; var upWidth = 0; var downCol = Colour.DarkRed; var downPen = Pen.Dot; var downWidth = 0; var lineCol1 = Colour.Grey; var linePen1 = Pen.Solid; var lineWidth1 = 0; var lineCol2 = Colour.Grey; var linePen2 = Pen.Solid; var lineWidth2 = 0; var lineCol3 = Colour.Grey; var linePen3 = Pen.Solid; var lineWidth3 = 0; function init(status) { if (status == Loading || status == Editing) { var store1 = restore(storage.getAt(0),[[upPen,0,5],[upWidth,0,7],[downPen,0,5],[downWidth,0,7],[linePen1,0,5],[lineWidth1,0,7],[linePen2,0,5],[lineWidth2,0,7]]); upPen = store1[0][0]; upWidth = store1[1][0]; downPen = store1[2][0]; downWidth = store1[3][0]; linePen1 = store1[4][0]; lineWidth1 = store1[5][0]; linePen2 = store1[6][0]; lineWidth2 = store1[7][0]; var store2 = restore(storage.getAt(1),[[linePen3,0,5],[lineWidth3,0,7],[period,2,5000],[topBox,0,1],[midBox,0,1],[botBox,0,1]]); linePen3 = store2[0][0]; lineWidth3 = store2[1][0]; period = store2[2][0]; topBox = store2[3][0]; midBox = store2[4][0]; botBox = store2[5][0]; var store3 = restore(storage.getAt(2),[[topValue,-100,100],[botValue,-100,100]]); topValue = store3[0][0]; botValue = store3[1][0]; upCol = unzipColours(storage.getAt(3))[0]; downCol = unzipColours(storage.getAt(3))[1]; lineCol1 = unzipColours(storage.getAt(4))[0]; lineCol2 = unzipColours(storage.getAt(4))[1]; lineCol3 = storage.getAt(5); } if (status == Adding || status == Editing) { dlg = new Dialog((status==Adding?"Add":"Edit")+" oscillator", 220, 132); dlg.addOkButton(); dlg.addCancelButton(); dlg.addGroupBox(5,8,153,45,"Oscillator properties:"); dlg.addIntEdit("VAL1",10,20,-1,-1,"","periods",period,2,5000); dlg.addColLinePicker("VAL2",120,18,-1,-1,"Oscillator line","",upCol,upPen,upWidth); //dlg.addColLinePicker("VAL3",120,35,-1,-1,"Aroon-Down","",downCol,downPen,downWidth); dlg.addGroupBox(5,60,153,65,"Horizontal lines:"); dlg.addTickBox("VAL4",10,72,15,-1,"",topBox); dlg.addTickBox("VAL5",10,89,-1,-1," 0",midBox); dlg.addTickBox("VAL6",10,106,15,-1,"",botBox); dlg.addIntEdit("VAL7",30,72,-1,-1,"","",topValue,-100,100); //dlg.addIntEdit("VAL8",20,80,-1,-1,"","",midValue,0,100); dlg.addIntEdit("VAL9",30,106,-1,-1,"","",botValue,-100,100); dlg.addColLinePicker("VAL10",120,71,-1,-1,"","",lineCol1,linePen1,lineWidth1); dlg.addColLinePicker("VAL11",120,88,-1,-1,"","",lineCol2,linePen2,lineWidth2); dlg.addColLinePicker("VAL12",120,105,-1,-1,"","",lineCol3,linePen3,lineWidth3); if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("VAL1"); upCol = dlg.getValue("VAL2").colour; upPen = dlg.getValue("VAL2").pen; upWidth = dlg.getValue("VAL2").width; //downCol = dlg.getValue("VAL3").colour; //downPen = dlg.getValue("VAL3").pen; //downWidth = dlg.getValue("VAL3").width; topBox = dlg.getValue("VAL4"); midBox = dlg.getValue("VAL5"); botBox = dlg.getValue("VAL6"); topValue = dlg.getValue("VAL7"); //midValue = dlg.getValue("VAL6"); botValue = dlg.getValue("VAL9"); lineCol1 = dlg.getValue("VAL10").colour; linePen1 = dlg.getValue("VAL10").pen; lineWidth1 = dlg.getValue("VAL10").width; lineCol2 = dlg.getValue("VAL11").colour; linePen2 = dlg.getValue("VAL11").pen; lineWidth2 = dlg.getValue("VAL11").width; lineCol3 = dlg.getValue("VAL12").colour; linePen3 = dlg.getValue("VAL12").pen; lineWidth3 = dlg.getValue("VAL12").width; storage.setAt(0, compress([[upPen,0,5],[upWidth,0,7],[downPen,0,5],[downWidth,0,7],[linePen1,0,5],[lineWidth1,0,7],[linePen2,0,5],[lineWidth2,0,7]])); storage.setAt(1, compress([[linePen3,0,5],[lineWidth3,0,7],[period,2,5000],[topBox,0,1],[midBox,0,1],[botBox,0,1]])); storage.setAt(2, compress([[topValue,-100,100],[botValue,-100,100]])); storage.setAt(3, zipColours(upCol,downCol)); storage.setAt(4, zipColours(lineCol1,lineCol2)); storage.setAt(5, lineCol3); } setSeriesColour(0,upCol); setSeriesLineStyle(0,upPen,upWidth); //setSeriesColour(1,downCol); //setSeriesLineStyle(1,downPen,downWidth); setSeriesColour(1,lineCol1); setSeriesLineStyle(1,linePen1,lineWidth1); setSeriesColour(2,lineCol2); setSeriesLineStyle(2,linePen2,lineWidth2); setSeriesColour(3,lineCol3); setSeriesLineStyle(3,linePen3,lineWidth3); setTitle(period+" Aroon Osc."); setRange(Range.MinMax,-100,100); } function getGraph(share, data) { var aroon = new Array(); var aroon1 = new Aroon(period); var upLine = new Array(); var downLine = new Array(); var oscLine = new Array(); var topLine = new Array(); var midLine = new Array(); var botLine = new Array(); for (var i=0; i8388608) print("Too much data for single storage space"); return output; } function restore(storage, data) { var remainder = storage; var rangeTot = 1; for (var i=0;i=0;i--) { if (i