Replies

marek.balla
08 Jan 2020, 11:31

Thank you Panagiotis Charalampous

for the reply

could you give me some idea about how to estimate it from the market depth? 

So there is no way to have the limit order to behave the same as market order, there is possibility to set the maximum allowed slippage.

For example: 

 public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, Symbol symbol, long volume, string label, double? stopLossPips, double? takeProfitPips, double? marketRangePips, Action<TradeResult> callback = null);

 

 has the marketRangePips parameter to define exactly that.

Isnt there any way to set that constraint to Pending limit order?

 

Couldnt it be this parameter ?

        //   stopLimitRangePips:
        //     Maximum distance for order execution from target price

in api method

public TradeResult ModifyPendingOrder(PendingOrder pendingOrder, double targetPrice, double? stopLossPips, double? takeProfitPips, DateTime? expirationTime, double volume, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopTriggerMethod? stopOrderTriggerMethod, double? stopLimitRangePips);

 

what exactly it means when i place a limit order? 

Many thanks for explanation

Regards Marek


@marek.balla

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

marek.balla
18 Nov 2019, 10:19

Hello, 

meanwhile i realized that it could be an possibility.

If someone is asking for 1 contract and someone is bidding 16 contracts, the price still dont have to move.

There have to come someone asking for 15 contracts to move then the price one tick up

Do i understand it correctly ? 

 

I would like to ask one more related question to this. 

Is it eventually possible with applying this logic to deduce the realized (bids x asks) using MarketDepth.Update API to implement an Orderflow indicator or its not possible without Times & Sales? ( which would be anyway great to have in cTrader when mt5 has it as well)

 

 


@marek.balla