//@LibraryID:909,3 //@Name:Stoch RSI Value //@Description:Returns the value of the Stochastic RSI. Can include intraday data if used as a column. //@Update:Periodic //@Width:70 //@Returns:Number // 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 rsiPeriod = 20; var stochPeriod = 20; var stochSlow = 2; var stochSignal = 9; var dataSource = 0; var dataList = ["Daily","Weekly","Monthly"]; var useIntra = 0; var returnList = ["Indicator","Signal"]; var returnType = 0; function init(status) { if (status == Loading || status == Editing) { rsiPeriod = storage.getAt(0); stochPeriod = storage.getAt(1); stochSlow = storage.getAt(2); stochSignal = storage.getAt(3); dataSource = storage.getAt(4); useIntra = storage.getAt(5); returnType = storage.getAt(6); } if (status == Adding || status == Editing) { var dlg = new Dialog("Stoch RSI",180,110); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("VAL1",5,5,-1,-1,"","RSI period",rsiPeriod,2,1000); dlg.addIntEdit("VAL2",5,22,-1,-1,"","Stoch period",stochPeriod,2,1000); dlg.addIntEdit("VAL3",5,39,-1,-1,"","Slowing period",stochSlow,1,1000); dlg.addIntEdit("VAL4",5,56,-1,-1,"","Signal period",stochSignal,2,1000); dlg.addDropList("VAL5",5,73,-1,-1,dataList,"","",dataSource); dlg.addTickBox("VAL6",75,75,100,-1,"Include Intraday Data",useIntra); dlg.addDropList("VAL7",45,90,50,-1,returnList,"Return the "," value.",returnType); if (dlg.show()==Dialog.Cancel) return false; rsiPeriod = dlg.getValue("VAL1"); stochPeriod = dlg.getValue("VAL2"); stochSlow = dlg.getValue("VAL3"); stochSignal = dlg.getValue("VAL4"); dataSource = dlg.getValue("VAL5"); useIntra = dlg.getValue("VAL6"); returnType = dlg.getValue("VAL7"); storage.setAt(0, rsiPeriod); storage.setAt(1, stochPeriod); storage.setAt(2, stochSlow); storage.setAt(3, stochSignal); storage.setAt(4, dataSource); storage.setAt(5, useIntra); storage.setAt(6, returnType); } setTitle(returnList[returnType]+": "+stochPeriod+"("+stochSlow+")"+stochSignal+" Stochastic of "+rsiPeriod+" RSI"+(useIntra?" (i":"(")+dataList[dataSource]+")"); } function getVal(share) { var data = getData(share,dataSource,useIntra); var rsi1 = new RSI(rsiPeriod); var stoch1 = new StochOsc(stochPeriod,stochSlow,stochSignal); var main = []; var signal = []; 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