//@Name:Above MA //@Description:Returns the % of shares in an index which are trading above the chosen MA //@Type:Historical // 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 indexList = ["FTSE100","FTSE250","FTSE350","FTSE All-Share","Dow Jones","Nasdaq 100","S&P 500"].concat(getPortfolioNames(false)); var listList = [List.FTSE100,List.FTSE250,List.FTSE350,List.FTSEAllShare,List.DJ30,List.NASDAQ100,List.US500]; var listNum = 0; var maList = ["Simple","Exponential","Weighted","Triangular","VariableVHF","VariableCMO","VIDYA"]; var maTitleList = ["SMA","EMA","WMA","TMA","VVHF","VCMO","VIDYA"]; var maPeriod = 50; var maType = 1; var lineCol = Colour.Red; var line1 = []; var baseShare; function init(status) { if (status == Loading || status == Editing) { listNum = storage.getAt(0); maPeriod = storage.getAt(1); maType = storage.getAt(2); lineCol = storage.getAt(3); } if (status == Adding || status == Editing) { var dlg = new Dialog("Up/Down Volume", 220, 85); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("DL1",8,-1,90,-1,indexList,"","",listNum); dlg.addDropList("DL2",8,-1,60,-1,maList,"","",maType); dlg.addIntEdit("INT1",8,-1,-1,-1,"","MA period",maPeriod,0,1000); dlg.addColPicker("COL1",100,27,-1,-1,"","",lineCol); dlg.addText(8,55,180,32,"The market graph shows how many shares are trading above the set moving average.\nThree lines are drawn at the 25%, 50% and 75% mark.") if (dlg.show()==Dialog.Cancel) return false; listNum = dlg.getValue("DL1"); maType = dlg.getValue("DL2"); maPeriod = dlg.getValue("INT1"); lineCol = dlg.getValue("COL1"); storage.setAt(0, listNum); storage.setAt(1, maPeriod); storage.setAt(2, maType); storage.setAt(3, lineCol); } var porList = getPortfolioNames(false); if (listNum<=6) var list = getList(listList[listNum]); else var list = getPortfolio(indexList[listNum]) var data = []; for (var i=0;ibaseShare.length) baseShare = list[i].getPriceArray(); } line1 = []; for (var i=0;ima1.getNext(data[i][j].close)) line1[data[i][j].dateNum]++; } } for (var i=0;i