//@Name:Upside-Downside Ratio //@Description:Returns a Upside Downside ratio as detailed in the A-Z of Technical Analysis by Steven B Achelis. // 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, ShareScript Support var listNum = 0; var indexList = ["FTSE100","FTSE250","FTSE350","FTSE All-Share","NYSE","Nasdaq","Nasdaq 100","Dow Jones 30","AMEX"]; var listList = [List.FTSE100,List.FTSE250,List.FTSE350,List.FTSEAllShare,List.NYSE,List.NASDAQ,List.NASDAQ100,List.DJ30,List.AMEX]; var baseData; var advDec = new Array(); var advDecAv = new Array(); var colour1=Colour.Red; var width1=1; var pen1=0; var USDSratio = new Array(); function init(status) { if (status == Loading || status == Editing) { listNum = storage.getAt(0); colour1 = storage.getAt(1); width1 = storage.getAt(2); pen1 = storage.getAt(3); } if (status == Adding || status == Editing) { var dlg = new Dialog("Settings...", 220, 60); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("VAL1",8,5,90,-1,indexList,"","",listNum); dlg.addColLinePicker("VAL2",128,5,-1,-1,"","",colour1,pen1,width1); dlg.addText(8,40,180,16,"Note that the indicator may take a few minutes to calculate") if (dlg.show()==Dialog.Cancel) return false; listNum = dlg.getValue("VAL1"); colour1 = dlg.getValue("VAL2").colour; pen1 = dlg.getValue("VAL2").pen; width1 = dlg.getValue("VAL2").width; storage.setAt(0, listNum); storage.setAt(1, colour1); storage.setAt(2, width1); storage.setAt(3, pen1); } setSeriesColour(0, colour1); setSeriesLineStyle(0, pen1, width1); setHorizontalLine(0); setTitle("Upside/Downside: "+indexList[listNum]); calculation(); } function getGraph(share,data) { var output = [] if(data==undefined || data.length<1) { return output; } for(i=0;idata.length) { var lengthDiff = output.length-data.length; return output.splice(lengthDiff) } else return output; } function calculation() { var advance = new Array(); var decline = new Array(); if(listNum<4) var baseshare=getShare("UKI:MCX"); else var baseshare=getShare("USI:DJI"); baseData=baseshare.getPriceArray(); //First we get the list of shares var list = getList(listList[listNum]); //Now we take each share in the list one at a time for (var a=0;aitemData[j-1].close) advance[i]=advance[i]+itemData[j].volume if (itemData[j].close