KazaTrade
Sign in
Menu

Symbols and quotes

Members of MT5API and of api.Symbols. Symbol names are exactly as the broker spells them, for example EURUSD, XAUUSD or EURUSD.m. Names are case-sensitive.

Check a symbol

bool Symbols.Exist(string symbol)

True if the broker offers symbol. Check a name here before you use it.

if (!api.Symbols.Exist("XAUUSD")) Console.WriteLine("Not offered by this broker");

string Symbols.ExistStartsWith(string symbol)

Returns the first symbol name that starts with symbol (for example "EURUSD" finds "EURUSD.m"), or null.

SymbolInfo Symbols.GetInfo(string symbol)

SymbolInfo Symbols.GetInfo(int id)

Returns the settings of one symbol. Public fields include Currency (the symbol name), Description, Digits, Points, Spread, TickSize, TickValue, ContractSize, ProfitCurrency, MarginCurrency, DepthOfMarket, Id, CalcMode, GTCMode, LowerLimit, UpperLimit.

SymGroup Symbols.GetGroup(string symbol)

Returns the trading rules of the symbol's group. Public fields include GroupName, TradeMode (Disabled, LongOnly, ShortOnly, CloseOnly, FullAccess), TradeType (Request, Instant, Market, Exchange), MinLots, MaxLots, LotsStep, SL, TP (the broker's stop-level numbers), SwapLong, SwapShort, SwapType, InitialMargin, MaintenanceMargin.

SymGroup g = api.Symbols.GetGroup("EURUSD");
Console.WriteLine($"Lots {g.MinLots} to {g.MaxLots}, step {g.LotsStep}");

SymGroup Symbols.GetGroupByName(string groupName)

Returns a group by its group name.

ComissionInfo Symbols.GetComission(string symbol)

Returns the commission rule for the symbol's group, or null if none matches.

Other Symbols members

bool IsQuoteSession(string symbol)

bool IsTradeSession(string symbol)

True if the server clock is inside a quote (or trade) session of symbol now.

Subscribe

You must subscribe to a symbol to get a stream of quotes. GetQuote and OrderSend subscribe for you when needed.

void Subscribe(string symbol)

Task SubscribeAsync(string symbol)

Starts quotes for one symbol. Calls Connect first if you are not connected.

void Subscribe(string[] symbols)

Task SubscribeAsync(string[] symbols)

Starts quotes for many symbols in one request. Throws InvalidSymbolException if any name does not exist.

Task SubscribeIgnoreNotExistAsync(string[] symbols)

Same, but silently skips names that do not exist.

void SubscribeForce(string[] symbols)

Task SubscribeForceAsync(string[] symbols)

Sends the subscribe request again even if the symbol is already subscribed. Use it to restart a stalled quote stream. Throws InvalidSymbolException for unknown names.

void SubscribeForceIgnoreNotExist(string[] symbols)

Task SubscribeForceIgnoreNotExistAsync(string[] symbols)

Force-subscribe, skipping unknown names.

void Unsubscribe(string symbol)

void Unsubscribe(string[] symbols)

Stops quotes.

string[] Subscriptions()

Lists the symbols you are subscribed to.

bool IsSubscribed(string symbol)

True if symbol is subscribed.

Quotes

Quote has Symbol, Bid, Ask, Last, Time (server time) and Volume.

Quote GetQuote(string symbol, int msTimeout = 0, int msNotOlder = 0)

Returns the latest quote. Connects if needed.

Quote q = api.GetQuote("EURUSD", 5000);

Task<Quote> GetQuoteAsync(string symbol, int msTimeout = 5000, int msNotOlder = 0)

Task<Quote> GetQuoteTask(string symbol, int msTimeout = 5000, int msNotOlder = 0)

Async form of GetQuote. Waits up to msTimeout. The two are the same call. Same errors.

Quote GetQuoteFromAnyServer(string symbol)

Returns the latest quote for symbol seen on any MT5API login in this process. It does not subscribe or wait. The name is not case-sensitive here. Returns null when no login has seen that exact name.

MarketWatch GetMarketWatch(string symbol)

Task<MarketWatch> GetMarketWatchAsync(string symbol)

Returns the Market Watch row: Symbol, Bid, Ask, High, Low, OpenPrice, ClosePrice, DailyChange, Spread, Volume. Waits for a quote first (GetQuoteTimeoutMs).

DateTime LastQuoteTime { get; }

When the last quote arrived on any symbol.

event OnQuote

Raised for every quote. See events.md.

Tick size and tick value

double GetTickSize(string symbol)

Smallest price step. Uses Points when the broker sets no tick size.

double GetTickValue(string symbol, int msGetQuoteTimeout = 10000)

Task<double> GetTickValueAsync(string symbol, int msGetQuoteTimeout = 10000)

Value of one tick for one lot, in the account currency. May wait for a quote when the broker gives no value.

double GetBidTickValue(Quote quote)

Task<double> GetBidTickValueAsync(Quote quote)

double GetAskTickValue(Quote quote)

Task<double> GetAskTickValueAsync(Quote quote)

Tick value at the bid or at the ask of the symbol in quote.

Bars (candles)

Bar has Time, OpenPrice, HighPrice, LowPrice, ClosePrice, TickVolume, Volume, Spread. timeFrame is in minutes: 1, 5, 15, 30, 60, 240, 1440 and so on. Values above 60 must be a multiple of 60.

The broker sends one-minute bars. The library builds other time frames from them. Download only what you need, and keep what you download.

Bar[] DownloadQuoteHistory(string symbol, DateTime from, DateTime to, int timeFrame)

Task<Bar[]> DownloadQuoteHistoryAsync(string symbol, DateTime from, DateTime to, int timeFrame)

Returns bars between from and to, oldest first. Downloads month by month.

Bar[] bars = api.DownloadQuoteHistory("EURUSD", DateTime.UtcNow.AddDays(-7), DateTime.UtcNow, 60);

List<Bar> DownloadQuoteHistoryMonth(string symbol, int year, int month, int day, int timeFrame, int timeoutMs = 15000)

Task<List<Bar>> DownloadQuoteHistoryMonthAsync(...)

Downloads the month that ends at the given date.

List<Bar> DownloadQuoteHistoryToday(string symbol, int timeFrame, int timeoutMs = 15000)

Task<List<Bar>> DownloadQuoteHistoryTodayAsync(string symbol, int timeFrame, int timeoutMs = 15000)

Downloads the most recent bars (the current day). Same errors.

List<Bar> ConvertToTimeframe(List<Bar> bars, int minutes)

Builds bars of minutes from one-minute bars. With 1 it returns the list unchanged.

void RequestQuoteHistoryMonth(string symbol, int year, int month, int day)

void RequestQuoteHistoryToday(string symbol)

void RequestQuoteHistoryTodayInternal(string symbol)

Ask for bars and get the answer through OnQuoteHistory instead of a return value. RequestQuoteHistoryTodayInternal does the same as RequestQuoteHistoryToday.

Ticks

void TickHistoryRequest(string symbol, int startYear, int startMonth, int startDay)

Starts a tick download from the given date. Ticks arrive through OnTickHistory as TickBar rows: Time, Bid, Ask, Last, Volume.

void TickHistoryStop(string symbol)

Ends the tick request for symbol so you can start a new one.

Order book (market depth)

void SubscribeOrderBook(string symbol)

void UnsubscribeOrderBook(string symbol)

Start or stop depth-of-market updates. Updates arrive through OnOrderBook. Not every symbol has a book (SymbolInfo.DepthOfMarket tells).

Symbols and quotes · MT5 library reference