Inside OnTick() in MT5

 

I newbie in metatrader 5 and I found documentation on onTick() function and newTick event is somehow ambiguous. My aim is to count the number of executed market orders provided that the broker gives data with this granularity. In other words, consider this example: you have a Seller of 10 contracts at $100 and those 10 contracts are bought by 3 Buyers (one buys 2 contracts, another buys 7 contracts and the 3rd buys 1 contract - all at $100);  or by the same Buyer, but in three different moments. I would like to count 3 orders, not 1 order. I wonder if i can use onTick() for this. More particularly, I have not understood if the inTick event is triggered when

  1. a new bid or ask order is placed, even if this is at a price for which there are other existing and waiting bid / ask offers in the DOM
  2. a new bid or ask order is placed, but just if this has a price without other waiting offers in the DOM
  3. a market order is executed in the DOM because a new buying offer matches and existing and waiting for selling offer or vice versa.

The MT5 manual says newTick is generated when "there are new quotes" but I cannot understand which of the 3 above case refers to and if i can use it for the purpose I described above.

Thanks.

 

The function onTick() is called by the local terminal when a new tick arrives. It can happen that for a certain period the broker (liquidity provider) does not offer any prices (e.g. news) or your pc/terminal is buzzy so that some ticks are ignored.

When and what ticks are sent or not is not in our hands.

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 

dear carl, thank you; but my doubt is around the definition of tick, in this case, and new price. I found diffent contextual definitions. what is a new price? A "market order" so when a new offer immediatly match a pending one in the ask/bid book? Or is it a new price put in the waiting orders in the book for which there where no other offers before? Or again, is it a new order placed in waiting condition in the book possibly adding it's required volume to a price for which there were other offers in waiting condition?

Thanks.

Reason: