//@Name:Trend Slope Value //@Description:Determine share's trend slope //@Returns:Number //@Width:90 //@Periodic:60 // 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. // Author: Phil Tolhurst, ShareScript Support var period=25; // number of trading days to look back for a trend var useIntra=0; var dataList = ["Daily","Weekly","Monthly"]; var dataSource = 0; function init(status) { if (status == Loading || status == Editing) { period = storage.getAt(0); useIntra = storage.getAt(1); dataSource = storage.getAt(2); } if (status == Adding || status == Editing) { dlg = new Dialog("Setup",160,65); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("VAL1",5,5,-1,-1,"","Trend period",period,2,5000); dlg.addTickBox("VAL2",60,51,120,-1,"Include Intraday Data",useIntra); dlg.addDropList("VAL3",5,50,50,-1,dataList,"","",dataSource); if (dlg.show()==Dialog.Cancel) return false; period = dlg.getValue("VAL1"); useIntra = dlg.getValue("VAL2"); dataSource = dlg.getValue("VAL3"); storage.setAt(0, period); storage.setAt(1, useIntra); storage.setAt(2, dataSource); } setTitle("Trend Slope Value ("+period+" "+(useIntra?"i":"")+dataList[dataSource]+")"); } function getVal(share) { //Obtain the correct set of data. var data = getData(share,dataSource,useIntra); if (data == undefined || data.length==undefined || data.length<2) return; //create the trend object var trendCalc = new Trend(period); //calculate the trend values including the slope. for (var i=0;idata[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