//@Name:Adv-Dec Oscillator //@Description:Returns the Advances minus the Declines of a list of shares as an oscillator pivoting around 0 // 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: Melissa Kearney, ShareScript Support //Modified by: Phil Tolhurst, ShareScript Support var listNum = 0; var indexList = ["FTSE100","FTSE250","FTSE350","FTSE All-Share","Nasdaq 100","Dow Jones 30","NYSE","Nasdaq","AMEX"]; var listList = [List.FTSE100,List.FTSE250,List.FTSE350,List.FTSEAllShare,List.NASDAQ100,List.DJ30,List.NYSE,List.NASDAQ,List.AMEX]; var baseData; var advDec = new Array(); var advDecAv = new Array(); var colour1=Colour.RGB(0,220,150); var width1=1; var pen1=0; var colour2=Colour.RGB(220,0,150); var width2=1; var pen2=0; var useIntra = 0; var dataSource = 0; var output=[]; function init(status) { if (status == Loading || status == Editing) { listNum = storage.getAt(0); colour1 = storage.getAt(1); colour2 = storage.getAt(2); } if (status == Adding || status == Editing) { var dlg = new Dialog("Advance/Decline Oscilator", 160, 80); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("DL1",8,5,90,-1,indexList,"","",listNum); dlg.addColPicker("COL1",60,-1,-1,-1,"Pos Colour","",colour1,pen1,width1); dlg.addColPicker("COL2",60,-1,-1,-1,"Neg Colour","",colour2,pen2,width2); dlg.addText(8,60,140,16,"Note that the indicator may take a few minutes to calculate") if (dlg.show()==Dialog.Cancel) return false; listNum = dlg.getValue("DL1"); colour1 = dlg.getValue("COL1"); colour2 = dlg.getValue("COL2"); storage.setAt(0, listNum); storage.setAt(1, colour1); storage.setAt(2, colour2); } setSeriesChartType(0, ChartType.Histogram); setSeriesColourMode(0, ColourMode.PosNeg); setSeriesColour(0, colour1, colour2); setRange(0, Range.CentraZero); setHorizontalLine(0); setTitle("("+indexList[listNum]+") Advances-Declines Oscillator"); if(listNum<4) var baseShare=getShare("UKI:UKX"); else var baseShare=getShare("USI:DJI"); //Check for intraday data. If the date of the last bar of the data passed to us from the indicator var baseData = getData(baseShare,0,0); //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;a0) { if(data[i]>data[i-1]) output[i]+=1; if(data[i]csData.length) { ADO.splice(0,(ADO.length-csData.length)); } if(ADO.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