/*@Name:Relative Strength New High-Low @Description:Shows if the relative strength has reached new highs or lows @Returns:Number */ /* Returns 1 if the share's relative strength against the index share has reached new highs or -1 if the share's relative strength has reached new lows. Returns 0 if neither occur. */ // 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 lookback = 250; var relShare = 0; var useIntraday = 0; var indexList = ["FTSE100","FTSE250","FTSE350","FTSE All-Share","DowJones Ind.Av.","NasdaqComp","Nasdaq100","S&P500","SectorIndex"]; var relShareList = [getShare("UKI:UKX"),getShare("UKI:MCX"),getShare("UKI:NMX"),getShare("UKI:ASX"),getShare("USI:DJI"), getShare("NAS:IXIC"),getShare("NAS:IXND"),getShare("USI:GSPC")]; function init(status) { if (status == Loading || status == Editing) { lookback = storage.getAt(0); relShare = storage.getAt(1); useIntraday = storage.getAt(2); } if (status == Adding || status == Editing) { dlg = new Dialog("Relative Strength", 165, 84); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("list", 8, -1, 80, -1, indexList, "", "", relShare); dlg.addIntEdit("back", 42, 25, 25, -1, "Look back", "trad. days", lookback, 1, 5000); dlg.addTickBox("TB1", 8, -1, -1, -1, "use intraday", useIntraday); dlg.addText(8, 55, 150, 25, "Returns the relative strength of the share against the chosen index. Will return blank if a share's history is shorter than the look back period"); if (dlg.show()==Dialog.Cancel) return false; relShare = dlg.getValue("list"); lookback = dlg.getValue("back"); useIntraday = dlg.getValue("TB1"); storage.setAt(0, lookback); storage.setAt(1, relShare); storage.setAt(2, useIntraday); } setTitle("Rel to "+indexList[relShare]+" ("+lookback+"td"+(useIntraday?" - intraday)":")")); } function getVal(share) { var data = share.getCloseArray(); if (relShare==8) relShareList[8] = share.getSectorIndex(); if (relShareList[relShare] == null) return; var relData = relShareList[relShare].getCloseArray(); if (data.lengthrel2) { NL = 0; if (NH == 0) break; } } return NH+NL; }