Download MetaTrader 5

How fast is OnTick function. Can there be loss in tick data?

To add comments, please log in or register
raghavanp
13
raghavanp  

I am doing auto trading in binary options which expire after exact 60 seconds.

I call OrderSend function when EA is initialized using init() function.

I record the time in millisecond both before(say TimeA) and after(say TimeB) OrderSend function is called. When a new order is placed, an entry is being placed in Experts tab in terminal. When I  compare this time(in millisecond precision with TimeA and TimeB, TimeB is matching with the time whatever is stated in Expert tab. I also see 300 to 400 ms time difference between TimeA and TimeB. (time taken by orderSend function)

OrderSend function uses "Bid" parameter. My first question is at what time this Bid parameter is taken from server in order to place this order. Is "Bid" price taken at TimeA or TimeB or sometime in between TimeA and TimeB?

I also have OnTick() function and I start storing(I use array to store and later write this array to file in DeInit() function) every tick data then onwards.  After 60 seconds(including millisecond precision), my binary option is closed at a particular Bid price. Starting from TimeB(since this is the time that matches with Order opened time in Experts tab), I add 60 seconds(including millisecond precision) and check the bid price recorded in my file. 

To my surprise, the order closed price(as stated in account history) is not at all recorded as one of the tick data in my stored file. That makes me questioning if OnTick is really capturing every single tick data? Or is it my processing power of my machine which loses some data? Or am i doing mistake in my approach? Please help clarifying this. 

Alain Verleyen
Moderator
33605
Alain Verleyen  
raghavanp:

I am doing auto trading in binary options which expire after exact 60 seconds.

I call OrderSend function when EA is initialized using init() function.

I record the time in millisecond both before(say TimeA) and after(say TimeB) OrderSend function is called. When a new order is placed, an entry is being placed in Experts tab in terminal. When I  compare this time(in millisecond precision with TimeA and TimeB, TimeB is matching with the time whatever is stated in Expert tab. I also see 300 to 400 ms time difference between TimeA and TimeB. (time taken by orderSend function)

OrderSend function uses "Bid" parameter. My first question is at what time this Bid parameter is taken from server in order to place this order. Is "Bid" price taken at TimeA or TimeB or sometime in between TimeA and TimeB?

I also have OnTick() function and I start storing(I use array to store and later write this array to file in DeInit() function) every tick data then onwards.  After 60 seconds(including millisecond precision), my binary option is closed at a particular Bid price. Starting from TimeB(since this is the time that matches with Order opened time in Experts tab), I add 60 seconds(including millisecond precision) and check the bid price recorded in my file. 

To my surprise, the order closed price(as stated in account history) is not at all recorded as one of the tick data in my stored file. That makes me questioning if OnTick is really capturing every single tick data? Or is it my processing power of my machine which loses some data? Or am i doing mistake in my approach? Please help clarifying this. 

You can't create a reliable EA for binary options with MT4/MT5. As you can't send request directly with MT4 (unless you are using some third-party tool), all you can do is simulate your trades, but it will never be 100% accurate.

  • You can't have the exact same price as your BO broker.
  • MT4 use Bid/Ask price, there is only 1 price for BO.
  • The time needed to send your request will always be different from your BO broker.

To answer your topic question, you can also lost ticks with MT4.

To add comments, please log in or register