//@Name:Current day change from high or low //@Description:Shows how the mid price has changed from the current day high or low. //@Update:Intraday //@Returns:number //@Env:Production //@Width:50 // 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 period = 60 var outputList = ["Absolute Change","Percentage Change"]; var outputList2 = ["High","Low"]; var outputType = 1; var outputType2 = 0; function init(status) { if (status == Loading || status == Editing) { outputType = storage.getAt(0); outputType2 = storage.getAt(1); } if (status == Adding || status == Editing) { dlg = new Dialog("Settings",200,50); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("VAL1",8,-1,80,-1,outputList,"","",outputType); dlg.addDropList("VAL2",8,-1,80,-1,outputList2,"","",outputType2); if (dlg.show()==Dialog.Cancel) return false; outputType = dlg.getValue("VAL1"); outputType2 = dlg.getValue("VAL2"); storage.setAt(0, outputType); storage.setAt(1, outputType2); } //sets the title of the column if(outputType2 == 0) { setTitle("Mid"+(outputType==0?" change (in pence) since high":"% change since high")); } else { setTitle("Mid"+(outputType==0?" change (in pence) since low":"% change since low")); } } function getVal(share) { var quoteData = share.getIBarArray(0,86400); if (quoteData==undefined || quoteData.length<1) return; var currMid = share.getIMid(); var daysHigh = quoteData[0].high; var daysLow = quoteData[0].low; if(outputType2 == 0) { if (outputType == 0) return (currMid-daysHigh).toFixed(2); else return ((currMid/daysHigh-1)*100).toFixed(2); } else { if (outputType == 0) return (currMid-daysLow).toFixed(2); else return ((currMid/daysLow-1)*100).toFixed(2); } }