Is it possible to get current slippage in onTick?

Created at 29 Dec 2019, 23:08
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!
MA

marek.balla

Joined 13.11.2019

Is it possible to get current slippage in onTick?
29 Dec 2019, 23:08


Hi Everyone,

i would like to know whether there is a possibility to obtain current slippage in market. My use case would be to cancel pending limit order when slippage is above defined threshold. 

I know i can define slippage when placing market order but this is a different order type.

Is the PendingOrder.ModifyStopLimitRange somehow related to slippage or what is this parameter about? 

Thakn you very much

 


@marek.balla
Replies

PanagiotisCharalampous
30 Dec 2019, 09:09

Hi marek.balla,

You can write some code to estimate the slippage based on the market depth but it is not possible to know the exact slippage until the order is actually executed, since the markets constantly move.

Best Regards,

Panagiotis 

Join us on Telegram

 

 


@PanagiotisCharalampous

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

PanagiotisCharalampous
08 Jan 2020, 12:02

Hi Marek,

  1. Based on your order's volume and the available market depth, you need to estimate your position's VWAP e.g. if your order volume is 10 units and the market depth offers 3 units at price 1, two units at price 2 and 5 units at price 3 then your VWAP is ((3*1) + (2*2) + (5*3))/10 = 1.9.
  2. Limit order cannot behave like a market order since it already includes the worst price you can accept. The limit price is the limit to your slippage.

Best Regards,

Panagiotis 

Join us on Telegram

 

 


@PanagiotisCharalampous