How to obtain current ticker?

Created at 03 Nov 2019, 15:27
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CH

chernish2

Joined 03.11.2019

How to obtain current ticker?
03 Nov 2019, 15:27


Hello. I'm trying to get current ticker (ask and bid prices) by using this code:

var depthOfMarket = MarketData.GetMarketDepth("EURUSD");

But 

depthOfMarket.AskEntries.Count

seem to be equal to zero so I can't obtain a ticker.

How can I get current ticker value?


@chernish2
Replies

PanagiotisCharalampous
04 Nov 2019, 09:05

Hi chernish2,

Thanks for posting in our forum. Try the below

        var symbol = Symbols.GetSymbol("EURUSD");
        var askPrice = symbol.Ask;

Best Regards,

Panagiotis


@PanagiotisCharalampous

srubtsov
07 Nov 2019, 09:41

depthOfMarket.AskEntries.Count

seem to be equal to zero so I can't obtain a ticker.

This is true only for the situation actually after creating. Next MarketOfDepth events should return valid values.

 

Also, for symbol ticker is more convenient to use `Symbol.Tick` event

var symbol = Symbols.GetSymbol("EURUSD");
symbol.Tick += symbolTickEventArgs => Print(string.Format("Bid: {0}, Ask: {1}, Symbol object: {2}", symbolTickEventArgs.Bid, symbolTickEventArgs.Ask, symbolTickEventArgs.Symbol));

@srubtsov

chernish2
07 Nov 2019, 13:15

RE:

Panagiotis Charalampous said:

Hi chernish2,

Thanks for posting in our forum. Try the below

        var symbol = Symbols.GetSymbol("EURUSD");
        var askPrice = symbol.Ask;

Ok, this is perfectly fine! But I have some more questions.

1. When I'm doing 

Symbols.GetSymbols()

I'm getting a list of all available symbols like Forex, Metals, Indicies etc. How can I filter out only Forex (fiat) pairs?

2. I'm drawing a rectangle like this:

var rect = Chart.DrawRectangle("rect", MarketSeries.OpenTime[5], y1, MarketSeries.OpenTime.LastValue, y2, color);
rect.IsFilled = true;
rect.ZIndex = 1000;
rect.Color = Color.Chocolate;

How can I change its opacity and Z-Index? With any valy assigned to rect.ZIndex the thing still staying on top of everything.

Thank you!

 


@chernish2

PanagiotisCharalampous
07 Nov 2019, 14:04

Hi chernish2,

1) There is no way to separate symbols based on asset classes at the moment.

2) You can control the opacity of your object by modifying the alpha of your color.

2) At the moment objects drawn on the chart cannot move behind the candlesticks.

Best Regards,

Panagiotis


@PanagiotisCharalampous