Skip to content

GetSymbols Method

GetSymbols

Summary

Get multiple symbols at once.

Signature

1
public abstract Symbol[] GetSymbols(string[] symbolNames)

Parameters

Name Type Description
symbolNames string[] Names of the symbols you want to get

Return Value

Symbol[]

Declaring Type

cAlgo.API.Symbols

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 using cAlgo.API;
 namespace cAlgo
 {
     // This sample shows how to use Symbols collection to get symbols data
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class SymbolsSample : Indicator
     {
         protected override void Initialize()
         {
             var scrollViewer = new ScrollViewer
             {
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
                 BackgroundColor = Color.Gold,
                 Opacity = 0.7,
                 HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
                 VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
                 Height = 300
             };
             var grid = new Grid(Symbols.Count + 1, 2)
             {
                 BackgroundColor = Color.Gold,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
             };
             scrollViewer.Content = grid;
             grid.AddChild(new TextBlock
             {
                 Text = "Name",
                 Margin = 5,
                 ForegroundColor = Color.Black,
                 FontWeight = FontWeight.ExtraBold
             }, 0, 0);
             grid.AddChild(new TextBlock
             {
                 Text = "Description",
                 Margin = 5,
                 ForegroundColor = Color.Black,
                 FontWeight = FontWeight.ExtraBold
             }, 0, 1);
             for (int iSymbol = 1; iSymbol < Symbols.Count + 1; iSymbol++)
             {
                 var symbolName = Symbols[iSymbol];
                 var symbol = Symbols.GetSymbol(symbolName);
                 if (!symbol.MarketHours.IsOpened()) continue;
                 grid.AddChild(new TextBlock
                 {
                     Text = symbolName,
                     Margin = 5,
                     ForegroundColor = Color.Black,
                     FontWeight = FontWeight.ExtraBold
                 }, iSymbol, 0);
                 grid.AddChild(new Button
                 {
                     Text = symbol.Description,
                     Margin = 5,
                     ForegroundColor = Color.Black,
                     FontWeight = FontWeight.ExtraBold
                 }, iSymbol, 1);
             }
             Chart.AddControl(scrollViewer);
         }
         public override void Calculate(int index)
         {
         }
     }
 }

Last update: March 30, 2023