//@Name:CCI Value //@Description: Calculates the CCI value for a specified period. //@Returns:Number //@Width:90 //@Update:Periodic,15 //@Env:Production // 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 period=20; var daysAgo = 0; var dataList = ["Daily","Weekly","Monthly"]; var dyAgoList = ["td","wk","mnth"]; var dataChoice = 0; var useIntra = 0; function init(status) { if (status == Loading || status == Editing) { period = storage.getAt(0); dataChoice = storage.getAt(1); daysAgo = storage.getAt(2); useIntra = storage.getAt(3); } if (status == Adding || status == Editing) { var dlg = new Dialog("Enter Value", 210, 55); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("VAL1", 55, 5, -1, -1, "CCI Period:", "",period); dlg.addIntEdit("VAL3", 55, 22, -1, -1, "Periods Ago:", "",daysAgo); dlg.addDropList("VAL2",5,39,-1,-1, dataList,"","",dataChoice); dlg.addTickBox("VAL4",75,41,80,-1,"Include Intraday data",useIntra); if (dlg.show() == Dialog.Ok) { period=dlg.getValue("VAL1"); dataChoice=dlg.getValue("VAL2"); daysAgo = dlg.getValue("VAL3"); useIntra = dlg.getValue("VAL4"); storage.setAt(0, period); storage.setAt(1, dataChoice); storage.setAt(2, daysAgo); storage.setAt(3, useIntra); } else { return false; } } setTitle("CCI:"+period+" ("+(useIntra?"i"+dataList[dataChoice]:dataList[dataChoice])+")"+(daysAgo>0?(daysAgo>1?(daysAgo+" "+dyAgoList[dataChoice]+"s"):(daysAgo+" "+dyAgoList[dataChoice])):"")); } function getVal(share) { var data = getData(share,dataChoice,useIntra); if (data==undefined || data.lengthdata[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