//@Name:HighestHighLowestLow //@Description:Shows the Highest High or Lowest Low value over a specified period. //@Returns:Number //@Width:80 //@Update:Periodic //@Env:Production //Author: Phil Tolhurst, ShareScript 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 = 7; var outputList = ["Value of","Periods Since","% change from"]; var highLowList = ["Highest","Lowest"]; var highLowType = 0; var dataSourceList = ["High","Low","Close","Volume"]; var dataTypeList = ["Daily","Weekly","Monthly"]; var output = 0; var dataType = 0; var dataSource = 0; var useIntra = 0; function init(status) { if (status == Loading || status == Editing) { period = storage.getAt(0); output = storage.getAt(1); dataType = storage.getAt(2); useIntra = storage.getAt(3); dataSource = storage.getAt(4); highLowType = storage.getAt(5); } if (status == Adding || status == Editing) { dlg = new Dialog("Column Settings", 265, 65); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("VAL1",50,5,-1, -1, "Period","", period, 1, 5000); dlg.addDropList("VAL2",50,22,75,-1,outputList,"Output the ", "",output); dlg.addDropList("VAL5",170,22,35,-1,dataSourceList,"","",dataSource); dlg.addDropList("VAL6",128,22,40,-1,highLowList,"","",highLowType); dlg.addDropList("VAL3",90,5,45,-1,dataTypeList,"", "",dataType); dlg.addTickBox("VAL4",50,39,75,-1,"Use Intraday data",useIntra); if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("VAL1"); output = dlg.getValue("VAL2"); dataType = dlg.getValue("VAL3"); useIntra = dlg.getValue("VAL4"); dataSource = dlg.getValue("VAL5"); highLowType = dlg.getValue("VAL6"); storage.setAt(0, period); storage.setAt(1, output); storage.setAt(2, dataType); storage.setAt(3, useIntra); storage.setAt(4, dataSource); storage.setAt(5, highLowType); } setTitle(period+(useIntra?" (i":" (")+dataTypeList[dataType]+") "+outputList[output]+" "+highLowList[highLowType]+" "+dataSourceList[dataSource]); } function getVal(share) { var data = getData(share,dataType,useIntra); if(data == undefined || data.length<2) return; var tdSinceHigh; var tdSinceLow; var pcntChngHigh; var pcntChngLow; var highHigh; var lowLow; var start=0; var outputData = []; for (var a = 0;ahighHigh) { highHigh=outputData[i] tdSinceHigh = data.length-(1+i); if (i==data.length-1) { pcntChngHigh = 0; } else { pcntChngHigh = (data[data.length-1].close/outputData[i]-1)*100; } } if (outputData[i]data[data.length-1].high?idata[0].high:data[data.length-1].high), low:(idata[0].lowdata[data.length-1].high?idata[0].high:data[data.length-1].high), low:(idata[0].low