Terminal-Server Synchronization

 

Good morning

I looked at a lot of code on this subject

Codes in codebase, in this forum, and in the official doc
https://www.mql5.com/en/docs/series/timeseries_access

In the comments of this code we can read for the checkloadhistory() function
//--- force timeseries build with copytime()
//--- ask for built bars with bars()

This gives the impression that there would be functions that would have the potential to force synchronization between the terminal and the server.

That potentially other functions would also have access to this synchronization.

What is it really ?

Is the synchronization task independent and not subject to influence?

Is she influenceable?

The more I think about it, the more I tell myself that this task is completely independent and that the codes should only be written on the synchronization confirmation.


I think that
//--- force timeseries build
//--- ask for built bars
are wishes, but the reality is different.

Your opinions and if possible codes which would prove your words.

THANKS

Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
  • www.mql5.com
Organizing Data Access - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Why do you need to force synchronization?

Normally (from the "Note" in https://www.mql5.com/en/docs/series/copybuffer):
When requesting data from the indicator, if requested timeseries are not yet built or they need to be downloaded from the server, the function will immediately return -1, but the process of downloading/building will be initiated.

When requesting data from an Expert Advisor or script, downloading from the server will be initiated, if  the terminal does not have these data locally, or building of a required timeseries will start, if data can be built from the local history but they are not ready yet. The function will return the amount of data that will be ready by the moment of timeout expiration.

And if data are not yet formed (from the same link you posted https://www.mql5.com/en/docs/series/timeseries_access#synchronized):
Since a mql5 program can call data from any symbol and timeframe, there is a possibility that data of a necessary timeseries are not formed yet in the terminal or the necessary price data aren't synchronized with the trade server. In this case it's hard to predict the latency time.

Algorithms using "do-nothing" loops are not the best solution. The only exception in this case are scripts, because they do not have any alternative algorithm choice due to not having event handling. For custom indicators such algorithms, as well as any other "do-nothing" loops are strongly not recommended, because they lead to termination of calculation of all indicators and any other handling of price data of the symbol.

For Expert Advisors and indicators, it is better to use the event model of handling. If during handling of OnTick() or OnCalculate() event, data receipt for the required timeseries failed, you should exit the event handler, relying on the access availability during the next call of the handler.

In MQL5 Indicator/Example and Expert/Example there are several examples that show exactly how to deal when data is not yet available.
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Good morning

I didn't talk about copybuffer or a wait loop.

That's not my question.

My question is whether the synchronization process of the terminal with the server could be influenced by functions like ibars, bars, copytime, copyrates, etc., BarsCalculated?

My question is if the sync process is completely self-contained and all commands

like ibars, bars, copytime, copyrates, etc., BarsCalculated are just commands to know the synchronization status?

THANKS
 
Gerard Willia G J B M Dinh Sy #:
My question is whether the synchronization process of the terminal with the server could be influenced by functions like ibars, bars, copytime, copyrates, etc., BarsCalculated?

The answer is that if historical data has not been synchronized, those functions will be affected and cannot return the desired results (most will return -1 and throw 4401 error), so you need to synchronize historical data first. When loading indicators or EAs use different data than the current chart (different timeframes, different symbols)

 
Hello
That's not my question.....
I know that if synchronization is not done, it can generate errors (4401, 4806)

The question is, I repeat myself again. Is the synchronization manageable?

1 - By the terminal alone without any influence option
2 - Through the terminal with the possibility of influencing it
 
Gerard Willia G J B M Dinh Sy #: That's not my question..... I know that if synchronization is not done, it can generate errors (4401, 4806)

The question is, I repeat myself again. Is the synchronization manageable?

1 - By the terminal alone without any influence option
2 - Through the terminal with the possibility of influencing it

You are making it more difficult that what is necessary. There is no special "forced synchronisation".

Basically, the required steps are as follows:

  1. You request the necessary data (e.g. iBars, Bars, CopyTime, CopyRates, etc. ).
  2. If it is available and no errors are given, then all is well and nothing else is required.
  3. If an error is given because data is unavailable then you skip the current event (i.e. return from handler to give some time until synchronisation is completed).
  4. On the next event call (i.e. OnTick, OnCalculate, etc.) you repeat the process until data is available.
 
Gerard Willia G J B M Dinh Sy #:

Also, in the link (https://www.mql5.com/en/docs/series/timeseries_access#synchronized) you posted on your first message there is the answer to your questions:

We can't refer to a server directly, but any Copy-function automatically initiates request sending to a server, if the history in HCC format is not enough.


Documentation on MQL5: Timeseries and Indicators Access
Documentation on MQL5: Timeseries and Indicators Access
  • www.mql5.com
Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
THANKS
Reason: