//@Name:No of Sector New Highs/Lows //@Description:Shows the number of New Highs or Lows for a sector in ShareScope. For anything else it returns nothing. //@Returns:Number //@Width:100 //@Env:Production // 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: Phil Tolhurst, ShareScope Support var lookBackPeriod = 10; var highLowPeriod = 250; var outputList = ["New Highs","New Lows"]; var outputType = 0; var FTSE350sector = new Array(); var FTSEAllShareSector = new Array(); var shwSctOnly = 0; var highLowChoice = 0; function init(status) { if (status == Loading || status == Editing) { lookBackPeriod = storage.getAt(0); highLowPeriod = storage.getAt(1); outputType = storage.getAt(2); shwSctOnly = storage.getAt(3); highLowChoice = storage.getAt(4); } if (status == Adding || status == Editing) { var dlg = new Dialog("Select Settings:", 250, 185); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("Val1",65, 5, -1, -1, "High/Low Period","Trading Days",highLowPeriod,2,9999); dlg.addIntEdit("Val2",65, 25, -1, -1, "Look Back Period","Trading Days",lookBackPeriod,2,1000); dlg.addDropList("Val3", 85,45,-1,-1,outputList,"Return the number of ","",outputType); dlg.addTickBox("Val4", 10, 65, 150, -1, "Use Higher Highs and Lower Lows", highLowChoice); dlg.addText(10,77,200,100,"If this option is not ticked the script will only use Close values"); dlg.addTickBox("Val5", 10, 89, 150, -1, "Only show against Sector Indices", shwSctOnly); dlg.addText(10,103,200,100,"If this option is not ticked the script will display values against the shares rather than the sector indices"); dlg.addText(10,127,200,400,"If the column is shown against the FTSE 350 sector indices it will use the consituents of the 350 to calculate the result. The same applies to FTSE All-Share Sector Indices. Likewise if a Share is in the FTSE350 then only the FTSE350 consituents are used to calculate the result shown in the column if the share is in the FTSE Small-Cap then the FTSE All-Share consituents are used."); if (dlg.show() == Dialog.Ok) { highLowPeriod = dlg.getValue("Val1"); lookBackPeriod = dlg.getValue("Val2"); outputType=dlg.getValue("Val3"); highLowChoice=dlg.getValue("Val4"); shwSctOnly=dlg.getValue("Val5"); storage.setAt(0, lookBackPeriod ); storage.setAt(1, highLowPeriod); storage.setAt(2, outputType); storage.setAt(3, shwSctOnly); storage.setAt(4, highLowChoice); } else { return false; } } //setTitle("td since "+outputList[outputType]+" ("+MAperiod1+maListShort[MAtype1]+"/"+MAperiod2+maListShort[MAtype2]+")"); var list = getList(List.FTSE350); for (var i=0;i=data.length-(1+lookBackPeriod);k--) { if (highLowChoice==1?data[k].high:data[k].close==HH) { check = 1; break; } if (highLowChoice==1?data[k].low:data[k].close==LL) { check = 2; break; } } //If a highest high is found if (check==1) { var counted = 0; if (FTSE350sector.length==undefined || FTSE350sector.length<1) { FTSE350sector[0]={sector:list[i].getSector(),highs:1,lows:0}; FTSEAllShareSector[0]={sector:list[i].getSector(),highs:1,lows:0}; counted=1 } else { for (var m=0;m=data.length-(1+lookBackPeriod);k--) { if (data[k]==HH) { check = 1; break; } if (data[k]==LL) { check = 2; break; } } //If a highest high is found if (check==1) { var counted = 0; if (FTSEAllShareSector.length==undefined || FTSEAllShareSector.length<1) { FTSEAllShareSector[0]={sector:list[i].getSector(),highs:1,lows:0}; counted=1 } else { for (var m=0;m