//@Name:Ichimoku Delayed Cloud //@Description:Returns a 1 if the delayed line has moved above the cloud and a -1 if it moved below the cloud. Also allows intraday data to be used as part of the calculation. //@Returns:Number //@Width:90 //@Update:Periodic // 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. // Coded by: Phil Tolhurst, ShareScope Support var mediumInterval = 26; var shortInterval = 9; var longInterval = 52; var delayedInterval = 26; var useIntra=0; var dataList = ["Daily","Weekly","Monthly"]; var dataSource = 0; function init(status) { if (status == Loading || status == Editing) { mediumInterval = storage.getAt(0); shortInterval = storage.getAt(1); longInterval = storage.getAt(2); delayedInterval = storage.getAt(3); useIntra = storage.getAt(4); dataSource = storage.getAt(5); } if (status == Adding || status == Editing) { var dlg = new Dialog("Ichimoku Kumu", 200, 100); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("INT1",5,5,-1,-1, "","Medium Interval",mediumInterval,1,999); dlg.addIntEdit("INT2",5,20,-1,-1, "","Short Interval",shortInterval,1,999); dlg.addIntEdit("INT3",5,35,-1,-1, "","Long Interval",longInterval,1,999); dlg.addIntEdit("INT4",5,50,-1,-1, "","Delayed Interval",delayedInterval,1,999); dlg.addTickBox("VAL1",5,65,120,-1,"Include Intraday Data",useIntra); dlg.addDropList("DL1",5,80,-1,-1,dataList,"","",dataSource); if (dlg.show() == Dialog.Cancel) return false; mediumInterval = dlg.getValue("INT1"); shortInterval = dlg.getValue("INT2"); longInterval = dlg.getValue("INT3"); delayedInterval = dlg.getValue("INT4"); useIntra = dlg.getValue("VAL1"); dataSource = dlg.getValue("DL1"); storage.setAt(0, mediumInterval); storage.setAt(1, shortInterval); storage.setAt(2, longInterval); storage.setAt(3, delayedInterval); storage.setAt(4, useIntra); storage.setAt(5, dataSource); } setTitle("Ichimoku Delayed Cloud ("+(useIntra?"i":"")+dataList[dataSource]+")"); } function getVal(share) { var output; var HHCalc1 = new MinMax(mediumInterval); var LLCalc1 = new MinMax(mediumInterval); var HHCalc2 = new MinMax(shortInterval); var LLCalc2 = new MinMax(shortInterval); var HHCalc3 = new MinMax(longInterval); var LLCalc3 = new MinMax(longInterval); var HHRes3 = new Array; var LLRes3 = new Array; var data = getData(share,dataSource,useIntra); if (data == undefined || data.length secondPrecedingSpan[td]) && (firstPrecedingSpan[yd]> secondPrecedingSpan[yd])&& (data[t].close>firstPrecedingSpan[td]) && (data[y].closesecondPrecedingSpan[yd]))output =1; else if ((secondPrecedingSpan[td]> firstPrecedingSpan[td]) && (secondPrecedingSpan[yd]> firstPrecedingSpan[yd])&& (data[t].close>secondPrecedingSpan[td]) && (data[y].closefirstPrecedingSpan[yd]))output =1; else if ((firstPrecedingSpan[td]firstPrecedingSpan[yd])) output=-1; else if ((secondPrecedingSpan[td]firstPrecedingSpan[yd])) output=-1; return output; } function getData(share,dataSource,useIntra) { if (dataSource == 0)var data = share.getPriceArray(); if (dataSource == 1)var data = share.getWeeklyBarArray(); if (dataSource == 2)var data = share.getMonthlyBarArray(); if (data.length<2) return; if (dataSource==0 && useIntra==1) { //get a 24hour intraday bar var idata = share.getIBarArray(0,86400); //Check the bar is not undefined and has the correct length. //Check the date of the intraday data is today's date. //Check the date of the end-of-day data is not today's date. if (idata!=undefined && idata.length==1 && new Date().getDate()==idata[0].date.getDate() && new Date().getDate()!=data[data.length-1].date.getDate()) {//Add a new bar to the end of the current data array that adds the intraday Open,High,Low & Close data[data.length]={ open:share.getIOpen(), high:idata[0].high, low:idata[0].low, close:(share.getIClose()==null?share.getIMid():share.getIClose()), volume:idata[0].volume, dateNum:idata[0].dateNum}; } } if (dataSource==1 && useIntra==1) { //get a 24hour intraday bar var idata = share.getIBarArray(0,86400); //Check the bar is not undefined and has the correct length. //Check the date of the intraday data is today's date. //Check the date of the end-of-day data is not today's date. if (idata!=undefined && idata.length==1 && new Date().getDate()==idata[0].date.getDate() && new Date().getDate()!=data[data.length-1].date.getDate()) { if (idata[0].date.getDay()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