SymbolIsSynchronized() always returns false?

 

If I create an EA* and use SymbolIsSynchronized() on EURUSD for example:

int OnInit() {
   bool result = SymbolIsSynchronized("EURUSD");
   printf("sync status: %u", result);
   return(INIT_SUCCEEDED);
};

The terminal prints the following:

EURUSD,H1: sync status: 0

No matter what I do (change timeframes, re-attach the EA to EURUSD), it always displays 0 (false); does this function work for anyone else?

* I'm using an MT4 terminal, but the same happens using MT5.

Thanks in advance for any help.

 
pipsqueak1:

If I create an EA* and use SymbolIsSynchronized() on EURUSD for example:

The terminal prints the following:

No matter what I do (change timeframes, re-attach the EA to EURUSD), it always displays 0 (false); does this function work for anyone else?

* I'm using an MT4 terminal, but the same happens using MT5.

Thanks in advance for any help.

This function is not documented for mql4, it's not working and return error 4014.

4014

ERR_UNKNOWN_COMMAND

Unknown command

On mql5, there is no problem for me.

2016.03.29 21:36:25.988    __TEST__ (EURUSD,M1)    EURUSD synchro =1

 
Alain Verleyen:

This function is not documented for mql4, it's not working and return error 4014.

4014

ERR_UNKNOWN_COMMAND

Unknown command

On mql5, there is no problem for me.

2016.03.29 21:36:25.988    __TEST__ (EURUSD,M1)    EURUSD synchro =1

Thanks for your prompt reply, much appreciated.

I was using an old demo account in MT5 and when I created a new one, the terminal updated and it now works.

For reference, you can't use MarketWatch window symbols, instead you have to physically open the chart for the function to check synchronisation, which I presume forces the 1minute candle data download so the terminal can create the hcc history file(s) for all other timeframes.

Thanks again for your help.

 
pipsqueak1:

For reference, you can't use MarketWatch window symbols, instead you have to physically open the chart for the function to check synchronisation, which I presume forces the 1minute candle data download so the terminal can create the hcc history file(s) for all other timeframes.


From the experience with my own custom indicators, market watch symbols can be synchronized without an open chart.

If SymbolIsSynchronized returns false, the symbol will be immediately synced on the next incoming tick.

Maybe you want to checkout the Refresh command from the standard library.

https://www.mql5.com/en/docs/standardlibrary/expertclasses/expertbaseclasses/cexpert/cexpertrefresh

Documentation on MQL5: Standard Library / Trading Strategy Classes / Base classes for Expert Advisors / CExpert / Refresh
Documentation on MQL5: Standard Library / Trading Strategy Classes / Base classes for Expert Advisors / CExpert / Refresh
  • www.mql5.com
Standard Library / Trading Strategy Classes / Base classes for Expert Advisors / CExpert / Refresh - Reference on algorithmic/automated trading language for MetaTrader 5
 
timkrug:


From the experience with my own custom indicators, market watch symbols can be synchronized without an open chart.

If SymbolIsSynchronized returns false, the symbol will be immediately synced on the next incoming tick.

Maybe you want to checkout the Refresh command from the standard library.

https://www.mql5.com/en/docs/standardlibrary/expertclasses/expertbaseclasses/cexpert/cexpertrefresh

Why are you thinking the Refresh() command is related to this topic ?
 
Alain Verleyen:
Why are you thinking the Refresh() command is related to this topic ?

"Refresh

Updates all data."


Seems not to be totally unrelated, but it was only a guess, anyway.

If it's not relevant, I would be pleased to receive your explanation why so.

 
timkrug:

"Refresh

Updates all data."


Seems not to be totally unrelated, but it was only a guess, anyway.

If it's not relevant, I would be pleased to receive your explanation why so.

Refresh() command is to update your EA data from Terminal data.

SymbolIsSynchronize() is about Server data versus Terminal data.

 
Alain Verleyen:

Refresh() command is to update your EA data from Terminal data.

SymbolIsSynchronize() is about Server data versus Terminal data.

I admit, not fully understanding the difference between Terminal and Server data.

Is it like local (stored on my computer) vs. external (brokers server) data?

 
timkrug:

I admit, not fully understanding the difference between Terminal and Server data.

Is it like local (stored on my computer) vs. external (brokers server) data?

Yes..Terminal is your MT4 platform, running on your computer.
 
Alain Verleyen #:

Refresh() command is to update your EA data from Terminal data.

SymbolIsSynchronize() is about Server data versus Terminal data.

Hi Alain, for you the use of isSynchronized is only useful once in OnInit (to know if the symbol is connected to the server) instead Refresh when we want to be sure we have the latest data update? However, it is still possible that the symbol goes out of synchronisation...


hanks in advance!

 
pipsqueak1: If I create an EA* and use SymbolIsSynchronized() on EURUSD for example:
Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:
  1. Terminal starts.
  2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
  3. OnInit is called.
  4. For indicators OnCalculate is called with any existing history.
  5. Human may have to enter password, connection to server begins.
  6. New history is received, OnCalculate called again.
  7. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
Reason: