//@Name:Alarm - RSIxSignal //@Description:Returns 1 if the RSI had crossed above it's signal and -1 if it has crossed below. //@Returns:Number //@Width:60 //@Update:Periodic, 60 //@DefaultRangeMax:1 //@@DefaultRangeMin:-1 // 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 SIGperiod = 9; var RSItype = 0; var RSItypeList = ["Wilder","Exponential","Simple"]; var RSItitleList = ["Wild","Exp","Simp"]; var SIGtype = 0; var SIGtypeList = ["Simple","Exponential","Weighted","Triangular","VariableVHF","VariableCMO","VIDYA"]; var MAtitleList = ["SMA","EMA","WMA","TMA","VHF","CMO","VIDYA"] var useIntra=0; var dataList = ["Daily","Weekly","Monthly"]; var dataSource = 0; function init(status) { if (status == Loading || status == Editing) { RSIperiod = storage.getAt(0); SIGperiod = storage.getAt(1); RSItype = storage.getAt(2); SIGtype = storage.getAt(3); useIntra = storage.getAt(4); dataSource = storage.getAt(5); } if (status == Adding || status == Editing) { dlg = new Dialog((status==Adding?"Add":"Edit")+" indicator", 235, 55); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("VAL1",30,5,-1,-1,"RSI:","",RSIperiod,2,5000); dlg.addDropList("VAL2",90,5,-1,-1,RSItypeList,"Type","",RSItype); dlg.addIntEdit("VAL3",30,22,-1,-1,"Signal:","",SIGperiod,2,5000); dlg.addDropList("VAL4",90,22,-1,-1, SIGtypeList, "Type","",SIGtype); dlg.addDropList("VAL5",5,40,-1,-1,dataList,"","",dataSource); dlg.addTickBox("VAL6",75,42,120,-1,"Include Intraday Data",useIntra); if (dlg.show()==Dialog.Cancel) return false; RSIperiod = dlg.getValue("VAL1"); RSItype = dlg.getValue("VAL2"); SIGperiod = dlg.getValue("VAL3"); SIGtype = dlg.getValue("VAL4"); dataSource = dlg.getValue("VAL5"); useIntra = dlg.getValue("VAl6"); storage.setAt(0, RSIperiod); storage.setAt(1, SIGperiod); storage.setAt(2, RSItype); storage.setAt(3, SIGtype); storage.setAt(4, useIntra); storage.setAt(5, dataSource); } setTitle("RSI ("+RSIperiod+":"+RSItitleList[RSItype]+") x Signal "+SIGperiod+":"+MAtitleList[SIGtype]); } function getVal(share) { //This calls the getData() function, this function gets the relevant array of data //and if necessary modifies it to include intraday data. var data = getData(share,dataSource,useIntra); //Check that thre is data the script can use. if (data == undefined || data.length<(RSIperiod>SIGperiod?RSIperiod:SIGperiod)) return; var RSIres = new Array(); var SIGres = new Array(); var RSIcalc = new RSI(RSIperiod, RSItype) var SIGcalc = new MA(SIGperiod, SIGtype); for (var i=1; iSIGres[zeroTD]) { setValueForShare(share,1); return 1; } } else if(getValueForShare(share)!=-1) { if (RSIres[oneTD]>SIGres[oneTD] && RSIres[zeroTD]SIGres[oneTD] && RSIres[zeroTD]>SIGres[zeroTD]) { setValueForShare(share,0); } } } else { if (RSIres[oneTD]SIGres[zeroTD]) { return 1; } else if (RSIres[oneTD]>SIGres[oneTD] && RSIres[zeroTD]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