//@Name:Rolling Relative Strength //@Description:Returns the relative strength of the share against the chosen index. The starting point rolls forward as the days progress. //@Env:Production //@Type:Historical // 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 lookback = 250; //lookback period var useSector = 0; //use sector true/false var LineCol = Colour.Red; var LineStyle = 0; var LineWidth = 0; var baseShare = getShare("UKI:UKX"); var outputType = 0; function init(status) { if (status == Loading || status == Editing) { baseShare = getShare(storage.getAt(0),0); lookback = storage.getAt(1); useSector = storage.getAt(2); LineCol = storage.getAt(3); LineStyle = storage.getAt(4); LineWidth = storage.getAt(5); outputType = storage.getAt(6); } if (status == Adding || status == Editing) { dlg = new Dialog((status==Adding?"Add":"Edit")+" indicator", 225, 90); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",8,5,-1,-1,"","Lookback",lookback,2,5000) dlg.addSharePicker("SP1", 8, 21, -1, -1, "", "", baseShare); dlg.addColLinePicker("CL1",120,5,-1,-1,"","",LineCol,LineStyle,LineWidth); dlg.addDropList("DL1",120,21,35,-1,["Line","Histogram"],"","",outputType); dlg.addTickBox("TB1",10,38,100,-1,"Use sector index",useSector); dlg.addText(10,55,170,35,"If the the sctor index option is ticked the base share will be ignored."); if (dlg.show()==Dialog.Cancel) return false; lookback = dlg.getValue("INT1"); useSector = dlg.getValue("TB1"); baseShare = dlg.getValue("SP1"); LineCol = dlg.getValue("CL1").colour; LineStyle = dlg.getValue("CL1").pen; LineWidth = dlg.getValue("CL1").width; outputType = dlg.getValue("DL1"); storage.setAt(0, baseShare.getShareScopeID()); storage.setAt(1, lookback); storage.setAt(2, useSector); storage.setAt(3, LineCol); storage.setAt(4, LineStyle); storage.setAt(5, LineWidth); storage.setAt(6, outputType); } setSeriesColour(0,LineCol); if (outputType) { setSeriesChartType(0,ChartType.Histogram); setSeriesColourMode(0,ColourMode.PosNeg); var negColour = Colour.RGB(255-LineCol%256,255-Math.floor(LineCol%65536/256),255-Math.floor(LineCol/65536)); setSeriesColour(0,LineCol,negColour); } else { setSeriesColour(0,LineCol); setSeriesLineStyle(0,LineStyle,LineWidth); } setHorizontalLine(0); } function getGraph(share, data) { var output = []; output.length = data.length; var F1, S1, F2, S2; //if useSector is true, use sector index instead of selected base share if (useSector) { baseShare = share.getSectorIndex(); if (baseShare==undefined) { setTitle("No sector index available"); return output; } setTitle(lookback+" Rel.Str. against "+baseShare.getName()); } setTitle("Rel to "+baseShare.getName()+" ("+lookback+"td)"); for (var i=lookback;i