Skip to content

Symbol

Summary

Represents a currency pair.

Signature

1
public abstract interface Symbol

Namespace

cAlgo.API.Internals

Methods

Name Description
NormalizeVolumeInUnits Round the volume to the amount suitable for a trade.
QuantityToVolumeInUnits Convert Quantity (in lots) to Volume in units of base currency.
VolumeInUnitsToQuantity Convert Volume in units of base currency to Quantity (in lots).
NormalizeVolume Round the volume to the amount suitable for a trade.
QuantityToVolume Convert Quantity (in lots) to Volume in units of base currency.
VolumeToQuantity

Properties

Name Description
Ask { get; } Gets the current ask price for this symbol.
Bid { get; } Gets the current bid price for this symbol.
Spread { get; } Gets the current spread of this symbol.
PipSize { get; } Gets the pip size for current symbol.
Digits { get; } Gets the number of digits for the symbol.
TickSize { get; } Gets the tick size for the current symbol.
VolumeInUnitsMin { get; } Gets the minimum tradable amount.
VolumeInUnitsMax { get; } Gets the maximum tradable amount.
VolumeInUnitsStep { get; } Gets the minimum trade amount increment.
PipValue { get; } Gets the monetary value of one pip.This is the monetary value of one pip of the symbol when you started your cBot or initialized your indicator.Its not updated in real time and it remains constant.
TickValue { get; } Gets the monetary value of one tick.This is the monetary value of one tick of the symbol when you started your cBot or initialized your indicator.Its not updated in real time and it remains constant.
LotSize { get; } Gets the size of 1 lot in units of the base currency.
UnrealizedNetProfit { get; } Gets the sum of the unrealized Net profits of the positions of this Symbol.
UnrealizedGrossProfit { get; } Gets the sum of the unrealized Gross profits of the positions of this Symbol
DynamicLeverage { get; } Gets the dynamic leverage tiers for the symbol.
MarketHours { get; } Gets access to the symbol's trading sessions schedule.
Code { get; }
PointSize { get; }
VolumeMin { get; }
VolumeMax { get; }
VolumeStep { get; }
Leverage { get; }
PreciseLeverage { get; }

Events

Name Description
Tick Occurs on each incoming symbol ticks

Examples

1
2
3
4
5
6
7
 double bid = Symbol.Bid;
    double ask = Symbol.Ask;
    string code = Symbol.Code;
    int digits = Symbol.Digits;
    double pipSize = Symbol.PipSize;
    double pointSize = Symbol.PointSize;
    double spread = Symbol.Spread;
  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
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 using cAlgo.API;
 using cAlgo.API.Internals;
 using System;
 namespace cAlgo
 {
     // This sample indicator shows how to get a symbol data
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class SymbolSample : Indicator
     {
         private TextBlock _spreadTextBlock;
         private TextBlock _bidTextBlock;
         private TextBlock _askTextBlock;
         private TextBlock _unrealizedGrossProfitTextBlock;
         private TextBlock _unrealizedNetProfitTextBlock;
         private TextBlock _timeTillOpenTextBlock;
         private TextBlock _timeTillCloseTextBlock;
         private TextBlock _isOpenedTextBlock;
         private Symbol _symbol;
         [Parameter("Use Current Symbol", DefaultValue = true)]
         public bool UseCurrentSymbol { get; set; }
         [Parameter("Other Symbol Name", DefaultValue = "GBPUSD")]
         public string OtherSymbolName { get; set; }
         protected override void Initialize()
         {
             var grid = new Grid(24, 2)
             {
                 BackgroundColor = Color.Gold,
                 Opacity = 0.6,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
             };
             var style = new Style();
             style.Set(ControlProperty.Padding, 1);
             style.Set(ControlProperty.Margin, 2);
             style.Set(ControlProperty.BackgroundColor, Color.Black);
             style.Set(ControlProperty.FontSize, 8);
             _symbol = UseCurrentSymbol ? Symbol : Symbols.GetSymbol(OtherSymbolName);
             grid.AddChild(new TextBlock { Text = "Symbol Info", Style = style, HorizontalAlignment = HorizontalAlignment.Center }, 0, 0, 1, 2);
             grid.AddChild(new TextBlock { Text = "Name", Style = style }, 1, 0);
             grid.AddChild(new TextBlock { Text = _symbol.Name, Style = style }, 1, 1);
             grid.AddChild(new TextBlock { Text = "ID", Style = style }, 2, 0);
             grid.AddChild(new TextBlock { Text = _symbol.Id.ToString(), Style = style }, 2, 1);
             grid.AddChild(new TextBlock { Text = "Digits", Style = style }, 3, 0);
             grid.AddChild(new TextBlock { Text = _symbol.Digits.ToString(), Style = style }, 3, 1);
             grid.AddChild(new TextBlock { Text = "Description", Style = style }, 4, 0);
             grid.AddChild(new TextBlock { Text = _symbol.Description, Style = style }, 4, 1);
             grid.AddChild(new TextBlock { Text = "Lot Size", Style = style }, 5, 0);
             grid.AddChild(new TextBlock { Text = _symbol.LotSize.ToString(), Style = style }, 5, 1);
             grid.AddChild(new TextBlock { Text = "Pip Size", Style = style }, 6, 0);
             grid.AddChild(new TextBlock { Text = _symbol.PipSize.ToString(), Style = style }, 6, 1);
             grid.AddChild(new TextBlock { Text = "Pip Value", Style = style }, 7, 0);
             grid.AddChild(new TextBlock { Text = _symbol.PipValue.ToString(), Style = style }, 7, 1);
             grid.AddChild(new TextBlock { Text = "Tick Size", Style = style }, 8, 0);
             grid.AddChild(new TextBlock { Text = _symbol.TickSize.ToString(), Style = style }, 8, 1);
             grid.AddChild(new TextBlock { Text = "Tick Value", Style = style }, 9, 0);
             grid.AddChild(new TextBlock { Text = _symbol.TickValue.ToString(), Style = style }, 9, 1);
             grid.AddChild(new TextBlock { Text = "Volume In Units Max", Style = style }, 10, 0);
             grid.AddChild(new TextBlock { Text = _symbol.VolumeInUnitsMax.ToString(), Style = style }, 10, 1);
             grid.AddChild(new TextBlock { Text = "Volume In Units Min", Style = style }, 11, 0);
             grid.AddChild(new TextBlock { Text = _symbol.VolumeInUnitsMin.ToString(), Style = style }, 11, 1);
             grid.AddChild(new TextBlock { Text = "Volume In Units Step", Style = style }, 12, 0);
             grid.AddChild(new TextBlock { Text = _symbol.VolumeInUnitsStep.ToString(), Style = style }, 12, 1);
             grid.AddChild(new TextBlock { Text = "Ask", Style = style }, 13, 0);
             _askTextBlock = new TextBlock { Text = _symbol.Ask.ToString(), Style = style };
             grid.AddChild(_askTextBlock, 13, 1);
             grid.AddChild(new TextBlock { Text = "Bid", Style = style }, 14, 0);
             _bidTextBlock = new TextBlock { Text = _symbol.Bid.ToString(), Style = style };
             grid.AddChild(_bidTextBlock, 14, 1);
             grid.AddChild(new TextBlock { Text = "Spread", Style = style }, 15, 0);
             _spreadTextBlock = new TextBlock { Text = _symbol.Spread.ToString(), Style = style };
             grid.AddChild(_spreadTextBlock, 15, 1);
             grid.AddChild(new TextBlock { Text = "Unrealized Gross Profit", Style = style }, 16, 0);
             _unrealizedGrossProfitTextBlock = new TextBlock { Text = _symbol.UnrealizedGrossProfit.ToString(), Style = style };
             grid.AddChild(_unrealizedGrossProfitTextBlock, 16, 1);
             grid.AddChild(new TextBlock { Text = "Unrealized Net Profit", Style = style }, 17, 0);
             _unrealizedNetProfitTextBlock = new TextBlock { Text = _symbol.UnrealizedNetProfit.ToString(), Style = style };
             grid.AddChild(_unrealizedNetProfitTextBlock, 17, 1);
             grid.AddChild(new TextBlock { Text = "Time Till Open", Style = style }, 18, 0);
             _timeTillOpenTextBlock = new TextBlock { Text = _symbol.MarketHours.TimeTillOpen().ToString(), Style = style };
             grid.AddChild(_timeTillOpenTextBlock, 18, 1);
             grid.AddChild(new TextBlock { Text = "Time Till Close", Style = style }, 19, 0);
             _timeTillCloseTextBlock = new TextBlock { Text = _symbol.MarketHours.TimeTillClose().ToString(), Style = style };
             grid.AddChild(_timeTillCloseTextBlock, 19, 1);
             grid.AddChild(new TextBlock { Text = "Is Opened", Style = style }, 20, 0);
             _isOpenedTextBlock = new TextBlock { Text = _symbol.MarketHours.IsOpened().ToString(), Style = style };
             grid.AddChild(_isOpenedTextBlock, 20, 1);
             grid.AddChild(new TextBlock { Text = "Trading Sessions #", Style = style }, 21, 0);
             grid.AddChild(new TextBlock { Text = _symbol.MarketHours.Sessions.Count.ToString(), Style = style }, 21, 1);
             grid.AddChild(new TextBlock { Text = "Trading Session Week Days", Style = style }, 22, 0);
             var weekDays = string.Empty;
             for (var iSession = 0; iSession < _symbol.MarketHours.Sessions.Count; iSession++)
             {
                 var currentSessionWeekDays = string.Format("{0}({1})-{2}({3})", _symbol.MarketHours.Sessions[iSession].StartDay, _symbol.MarketHours.Sessions[iSession].StartTime, _symbol.MarketHours.Sessions[iSession].EndDay, _symbol.MarketHours.Sessions[iSession].EndTime);
                 weekDays = iSession == 0 ? currentSessionWeekDays : string.Format("{0}, {1}", weekDays, currentSessionWeekDays);
             }
             grid.AddChild(new TextBlock { Text = weekDays, Style = style }, 22, 1);
             grid.AddChild(new TextBlock { Text = "Leverage Tier", Style = style }, 23, 0);
             var leverageTiers = string.Empty;
             for (var iLeveragTier = 0; iLeveragTier < _symbol.DynamicLeverage.Count; iLeveragTier++)
             {
                 var currentLeverageTiers = string.Format("Volume up to {0} is {1}", _symbol.DynamicLeverage[iLeveragTier].Volume, _symbol.DynamicLeverage[iLeveragTier].Leverage);
                 leverageTiers = iLeveragTier == 0 ? currentLeverageTiers : string.Format("{0}, {1}", leverageTiers, currentLeverageTiers);
             }
             grid.AddChild(new TextBlock { Text = leverageTiers, Style = style }, 23, 1);
             Chart.AddControl(grid);
             _symbol.Tick += Symbol_Tick;
             Timer.Start(TimeSpan.FromSeconds(1));
         }
         private void Symbol_Tick(SymbolTickEventArgs obj)
         {
             _askTextBlock.Text = obj.Symbol.Ask.ToString();
             _bidTextBlock.Text = obj.Symbol.Bid.ToString();
             _spreadTextBlock.Text = obj.Symbol.Spread.ToString();
             _unrealizedGrossProfitTextBlock.Text = obj.Symbol.UnrealizedGrossProfit.ToString();
             _unrealizedNetProfitTextBlock.Text = obj.Symbol.UnrealizedNetProfit.ToString();
         }
         protected override void OnTimer()
         {
             _timeTillOpenTextBlock.Text = _symbol.MarketHours.TimeTillOpen().ToString();
             _timeTillCloseTextBlock.Text = _symbol.MarketHours.TimeTillClose().ToString();
             _isOpenedTextBlock.Text = _symbol.MarketHours.IsOpened().ToString();
         }
         public override void Calculate(int index)
         {
         }
     }
 }

Last update: July 1, 2022

Comments