I found the answer to all my questions here:

Implementing a Scalping Market Depth Using the CGraphic Library
- 2017.10.26
- Vasiliy Sokolov
- www.mql5.com
Now, we will start to work with this improved and revised version trying to gradually turn it into a scalping Market Depth tool. Overview of the CPanel graphics library There are many articles devoted to the creation of user interfaces in MQL5. Anatoly Kazharsky's "Graphical Interfaces" series stands out among them. It is difficult to add...

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I saw some differences between DOM timesandsales and CopyTicks in indicator.
I attach a simple Indicator as example and an image to explain it.
In the image on the left side there are datas exported from DOM (csv), on the right side there are datas saved by attached indicator using CopyTicks in the OnCalculate event.
I tried to match the common lines in the two file (white color) and highliht the mismatching lines (yellow color).
How we can see in the figure sometimes the DOM seems to loose same datas sometimes, and vice versa sometimes the Indicator seem to loose some other datas.
It's curiose that if we export for example the last 1000 ticks from DOM and we write a script, that runs once, using "CopyTicks" function with the same number ticks, the result is the same as DOM.
Here this second kind of code (the script that save 1000 ticks):
It seems like the DOM show a statically snapshots of market, but in real market sometimes DOM looses some datas, and sometimes the indicator looses some datas.
My question are:
Why if OnCalculate is called after every arrival of each tick, if I use CopyTicks to get 1 ticks, I get different result vs export of DOM?
Why if in a script if is called Copyticks for multiple ticks the DOM and the script give the same results?
In mql5 documentation (https://www.mql5.com/en/docs/series/copyticks) I read this:
-) In indicators, the OnCalculate() function is called after the arrival of each tick.
-) OnTick() in Expert Advisor is not a handler of every tick, it only notifies an Expert Advisor about changes in the market. It can be a batch of changes: the terminal can simultaneously make a few ticks, but OnTick() will be called only once to notify the EA of the latest market state.
In documentation it's said thath OnTick may join more ticks. I'm afraid that the same thing is done with OnCalculate.
How can we reproduce the "real" tick by tick flow in an Indicator?
I even tried using SymbolInfoTick, but results don't seem get better!
every suggestion is accepted.