//@LibraryID:919,1 // @Name:Sector above MA. // @Description:Returns 1 if a share's sector (based on the FTSE 350 sectors) is above a user definable MA. // @Returns:Number // @Width:95 // 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 maPeriod = 20 var maType = 0 var maTitleList = ["SMA","EMA","WMA","TMA","VVHF","VCMO","VIDYA"]; var maList = ["Simple","Exponential","Weighted","Triangular","VariableVHF","VariableCMO","VIDYA"]; var dataSource = 0; var dataList = ["Daily","Weekly","Monthly"]; var result = new Array(); function init(status) { if (status == Loading || status == Editing) { maPeriod = storage.getAt(0); maType = storage.getAt(1); dataSource = storage.getAt(2); } if (status == Adding || status == Editing) { dlg = new Dialog("Settings...", 250, 75); dlg.addOkButton(); dlg.addCancelButton(); dlg.addIntEdit("VAL1",65,5,20,-1,"Moving Average: ","",maPeriod); dlg.addDropList("VAL2",95,5,61,-1,maList,"","",maType); dlg.addDropList("VAL3",65,22,45,-1,dataList,"Data Source:","",dataSource); if (dlg.show()==Dialog.Cancel) return false; maPeriod = dlg.getValue("VAL1"); maType = dlg.getValue("VAL2"); dataSource = dlg.getValue("VAL3"); storage.setAt(0, maPeriod); storage.setAt(1, maType); storage.setAt(2, dataSource); } setTitle("Sector Above "+maPeriod+maTitleList[maType]+" ("+dataList[dataSource]+")"); var sectorList=getList(List.FTSE350SectorIndices); for(var j=0;jmaRes); } } function getVal(share) { for(i=0;i