//@Name:RSI_Cross //@Description: Checks for RSIs Crossing and returns 1 when the first crosses above the second and -1 when the first crosses below the second. //@Returns:Number //@Width:88 //@Update:periodic,15 var Value1=Value2=10 var RSIType1=RSIType2=0; var RSIList = ["Wilder","Exponential","Simple"]; function init(status) { if (status == Loading || status == Editing) { RSIType1 = storage.getAt(0); RSIType2 = storage.getAt(1) Value1 = storage.getAt(2); Value2 = storage.getAt(3); } if (status == Adding || status == Editing) { var dlg = new Dialog("Enter Value", 200, 70); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("Value1", 65, -1, -1, -1, "Period", "days", Value1); dlg.addDropList("RSIType1",65,-1,-1,-1, RSIList, "First RSI Type","",0); dlg.addIntEdit("Value2", 65, -1, -1, -1, "Second RSI Period", "days", Value2); dlg.addDropList("RSIType2",65,-1,-1,-1, RSIList, "Second RSI Type","",0); if (dlg.show() == Dialog.Ok) { Value1=dlg.getValue("Value1") storage.setAt(2, Value1); Value2=dlg.getValue("Value2") storage.setAt(3, Value2); RSIType1=dlg.getValue("RSIType1") storage.setAt(0, RSIType1); RSIType2=dlg.getValue("RSIType2") storage.setAt(1, RSIType2); } else { return false; } } setTitle("RSI Cross: "+Value1+" "+RSIList[RSIType1]+" crossing "+Value2+" "+RSIList[RSIType2]); } function getVal(share) { var data = share.getPriceArray(); if (data.length<250) return; if (dateNum(new Date())>data[data.length-1].dateNum+5) return; var idata = share.getIBarArray(0,86400); if (idata!=undefined && idata.length==1 && new Date().getDate()==idata[0].date.getDate() && new Date().getDate()!=data[data.length-1].date.getDate()) { var tclose = share.getIClose(); data[data.length]={open:idata[0].open,high:idata[0].high,low:idata[0].low,close:(tclose==null?share.getIMid():tclose),volume:idata[0].volume}; } var RES1=new Array(); var RES2=new Array(); var output = 0 var RSI1 = new RSI(Value1,RSIType1); var RSI2 = new RSI(Value2,RSIType2); for (var i=0;i0)) output=1; if ((RES1[RES1.length-2]-RES2[RES2.length-2]>0) && (RES1[RES1.length-1]-RES2[RES2.length-1]<0)) output=-1; return output; }