There are two ways to get a list of stock symbols for a particular index using the global script tool. 1- Create a new symbols filter using the "Symbol -> Symbols View" tool - Right click on the control then click on "Create a new symbols filter" - Click on "Add Condition" then select "Index" - Double click on the cell under "Values", select an index then click on "OK" - Type a name for this symbols filter. Example: S&P500 - Open the script editor by selecting "Tools" then "Script Editor" - Create a new file then type the following formula: Symbol[] symbols = Symbols.GetSymbols("S&P500", ""); This will check for the "S&P500" symbols filter item and return all stocks referenced by this filter. 2- Another way to do this is by looping through all symbols and then checking whether a symbol is referenced by a particular index such as the S&P 500, the Dow Jones or the Russell 2000. List list = new List(); Symbol[] symbols = Symbols.GetSymbols(); for(int i=0;i < symbols.Length;i++) { Symbol symbol = symbols[i]; if(Array.IndexOf(symbol.GetIndexesFromList(), "S&P500") >= 0) { list.Add(symbol.Name); } } Note: In order to use the above scripts, indices must be referenced in symbols settings (Symbol -> Update or Symbol -> Manage Symbols)
|
|