Market Range in Pips

Created at 27 Nov 2013, 00:15
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!
Ravadre's avatar

Ravadre

Joined 26.11.2013

Market Range in Pips
27 Nov 2013, 00:15


Hello,

 I'd like to ask few questions about Market range in pips and how generally they work.

In general, I assume that this functionality is similar to 'Instant Execution' in MT4, where you could specify maximum slippage between price you see and price you will get (your order will be executed at). 

However, ExecuteMarketOrder function lets you pass marketRangePips, however, it doesn't let you pass reference price, so which price is taken as the 'reference' one? If it is current one, on the client side, is it possible that this price will change (I am assuming serial execution), for example:

double entry1 = Symbol.Ask;
await Task.Delay(3000);
double entry2 = Symbol.Ask;
Position res = ExecuteMarketOrder(TradeType.Buy, Symbol, 100000, "test", null, null, slippage).Position;
double entrya = res.EntryPrice;
                    

I have obviously observed difference between entry1 and entry2 (as I have switched threads and waited for few seconds), however, if it is possible, that entrya will differ from entry2 for more than slippage?

 

Secondly, how to properly pass marketRangePips? When filling MarketOrderRequest structure, you can pass `SlippagePips` as an int, so 1 will mean 1 pip (does 1 pip mean 5th or 4th decimal number for EURUSD? - I assume 4th as PipSize returns 0.0001 always).

However, when using ExecuteMarketOrder, you ought to pass a double, does that mean I should do some sort of conversion (slippageInPips * PipSize)?

I will be grateful for any light shed on this.


@Ravadre
Replies

Hyperloop
27 Nov 2013, 08:45

The reference price you mentioned is the current market price (bid for short, ask for long).

As for your second question, cAlgo recognizes the difference between pips and points (unlike some of its competitors). With that said, 1 = 1 pip.


@Hyperloop

Ravadre
27 Nov 2013, 19:12

Thank you for your answer.

Do you maybe know the answer to my last question?

However, when using ExecuteMarketOrder, you ought to pass a double, does that mean I should do some sort of conversion (slippageInPips * PipSize)?

I am still now sure how I should interpret difference in how slippage is passed between those 2 methods (int? in one, double? in the other). Theoretically, I we assume that ExecuteMarketOrder slip parameter expects double in 'price format' (for example, 0.0001 represents 1 pip) I could pass slippage as low as 1/10th of a pip (by passing 0.00001), which is smaller value than what I could get using old API (filling MarketOrderRequest) or through cTrader's GUI, which would be strange.

For the reference, I've also tested if Symbol.Ask/Bid could change between reading it once and calling ExecMarketOrder and the answer is no, as long as we are not doing this on our own thread (we have to block execution in OnStart, OnTick, OnBar).

So this code:

while (r)
{
   Print("Ask: " + Symbol.Ask);
   System.Threading.Thread.Sleep(300);
}

will return the same result when called directly from OnTick, but will update properly if called from our Thread (which means, theoretically, entry2 and entrya from my OP could differ).


@Ravadre

Hyperloop
27 Nov 2013, 21:13

Slippage in double means you can set it to a fraction of pips. Ex) 2.1 pips, 1.0 pips, etc.


@Hyperloop

Ravadre
27 Nov 2013, 21:16

RE:

Hyperloop said:

Slippage in double means you can set it to a fraction of pips. Ex) 2.1 pips, 1.0 pips, etc.

Great, so surprisingly this gives more possibilities than "old api" and cTrader as well.

Thanks.


@Ravadre

Hyperloop
27 Nov 2013, 21:40

Yes, I just updated my entire library of methods today to take advantage of all the new API features. :)


@Hyperloop