T&S with DOM and tick data

Created at 07 Jun 2014, 12: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!
AN

Antonma

Joined 31.05.2014

T&S with DOM and tick data
07 Jun 2014, 12:27


Hi All,

unfortunately there is no T&S data in ticks in cTrader available  like e.g. dukascopy has:

Time                                 Ask        Bid        AskVolume BidVolume

18.05.2014 21:00:03.399,139.064,139.042,1.50 (m),       1.50(m)

I thought I can try to create this data by myself because we have DOM data and we have tick data. So there are two events MarketDepth:Updated() and Robot:OnTick(). 

My questions:

Are they synchronized? It means, is the clear order that first OnTick event occurs and then 2. MD Updated or vice versa? So can I use the last updated DOM from OnTick or is it possible than DOM is updated more frequently that ticks occurs? Will I need to use a timestamp to synchronize DOM and tick data?

Thank you,

Anton

 

 


@Antonma
Replies

Spotware
10 Jun 2014, 08:24

OnTick and MaketDepth.Updated are not synchronized. Even more MarketDepth.Updated event occurs more frequent than Tick happens. We can recommend you to use MarketDepth.Updated event and retrieve spot prices from the MarketDepth object. 


@Spotware

Antonma
11 Jun 2014, 23:26

Ok, that is what I'm doing now:

1. Gather DOM Data before the next tick occurs

protected override void OnStart()
{
   md = MarketData.GetMarketDepth(Symbol);
   md.Updated += md_Updated;
}  
void md_Updated()
        {
            //Print("md updated: " + Server.Time.ToLongTimeString());

            foreach (var ask in md.AskEntries)
            {
                AskVolumeByPriceByBar.Add(new VolumeByPrice(ask.Price, ask.Volume));
            }

            foreach (var bid in md.BidEntries)
            {
                BidVolumeByPriceByBar.Add(new VolumeByPrice(bid.Price, bid.Volume));
            }
        }

2. When next tick occurs find the current ask and bid prices in gathered list of DOM data:

 protected override void OnTick()
 {
     ...
     List<VolumeByPrice> bidsf = BidVolumeByPriceByBar.FindAll(x => x.Price == Symbol.Bid);
     List<VolumeByPrice> asksf = AskVolumeByPriceByBar.FindAll(x => x.Price == Symbol.Ask);
     ...
     
 }

So assumed that the DOM data was updated 5 times before a new tick occurs which set (<List> index) of values form the DOM data can I take I order to represent the time and sales (T&S) of the current tick? 

Currently I take all DOM data that was changed between current and last tick for current ask and bid price in order to represent the T&S. But I don’t know if it is right.

 foreach (var bid in bidsf)
 {
        tempBidVolume += bid.Volume;
 }

 foreach (var ask in asksf)
 {
        tempAskVolume += ask.Volume;
  }

Any suggestions?

Thank you,

Anton 


@Antonma

marek.balla
23 Nov 2019, 14:28

RE:

Hello Anton 

Any update on this? I would like to achieve something similar, Mt5 has now T&S but cTrader still not. Is this possible with your approach? Thx

Antonma said:

Ok, that is what I'm doing now:

1. Gather DOM Data before the next tick occurs

protected override void OnStart()
{
   md = MarketData.GetMarketDepth(Symbol);
   md.Updated += md_Updated;
}  
void md_Updated()
        {
            //Print("md updated: " + Server.Time.ToLongTimeString());

            foreach (var ask in md.AskEntries)
            {
                AskVolumeByPriceByBar.Add(new VolumeByPrice(ask.Price, ask.Volume));
            }

            foreach (var bid in md.BidEntries)
            {
                BidVolumeByPriceByBar.Add(new VolumeByPrice(bid.Price, bid.Volume));
            }
        }

2. When next tick occurs find the current ask and bid prices in gathered list of DOM data:

 protected override void OnTick()
 {
     ...
     List<VolumeByPrice> bidsf = BidVolumeByPriceByBar.FindAll(x => x.Price == Symbol.Bid);
     List<VolumeByPrice> asksf = AskVolumeByPriceByBar.FindAll(x => x.Price == Symbol.Ask);
     ...
     
 }

So assumed that the DOM data was updated 5 times before a new tick occurs which set (<List> index) of values form the DOM data can I take I order to represent the time and sales (T&S) of the current tick? 

Currently I take all DOM data that was changed between current and last tick for current ask and bid price in order to represent the T&S. But I don’t know if it is right.

 foreach (var bid in bidsf)
 {
        tempBidVolume += bid.Volume;
 }

 foreach (var ask in asksf)
 {
        tempAskVolume += ask.Volume;
  }

Any suggestions?

Thank you,

Anton 


@marek.balla