symbol EURUSD synchronization error

 
I am trying to execute EA from article: https://www.mql5.com/en/articles/143 I get an error: symbol EURUSD synchronization error and LOG fiel contains also messages: Expert removed because indicator 26 cannot load [4801] and Error of creation of the MA indicator - error number: 4801!! does anybody have a clue where could be a problem? Thanks
Adaptive Trading Systems and Their Use in the MetaTrader 5 Client Terminal
  • 2010.09.14
  • MetaQuotes Software Corp.
  • www.mql5.com
This article suggests a variant of an adaptive system that consists of many strategies, each of which performs its own "virtual" trade operations. Real trading is performed in accordance with the signals of a most profitable strategy at the moment. Thanks to using of the object-oriented approach, classes for working with data and trade classes of the Standard library, the architecture of the system appeared to be simple and scalable; now you can easily create and analyze the adaptive systems that include hundreds of trade strategies.
 

How have you tried to execute EA? Where did you get error?

Attach full logs.


I loaded all files and executed EA successfully.

Any way check location of all indicator files are used. It is a common reason to get this error.

 
It is solved already. No Idea how... Terminal updated today Anyway, thanks for a help. Attached LOGs, with error from 20.10.2010 and from today without an error.
 

Hi guys,

Looks like this problem can still occur. My terminal cannot run strategy simulations with the EURUSD symbol and also not with the VIX symbol.

Here an excerpt of the critical passage of my log:


As you can see, there's that timeout of exactly 10 minutes until the Strategy Tester gives up and yields no tick data.

I tried clearing the history files so the Terminal would re-download these symbols (after opening charts of EURUSD and UsaVixNov19),

but the problem still persists.


Just for the sake of completeness, here's the code how I fetch the current bid price of the EURUSD symbol:

        if (InpSymbolAccountToSymbol != "") { // e.g. "EURUSD"
                bool wasSuccessfull = SymbolInfoDouble(InpSymbolAccountToSymbol, SYMBOL_BID, m_ConversionAcc2SymbolCurrency);
                if (wasSuccessfull) {
                        LogInit("Currency conversion factor for Symbol '" + InpSymbolAccountToSymbol + "': " + DoubleToString(m_ConversionAcc2SymbolCurrency));
                } else {
                
                        Alert("Error! " + ErrorDescription(GetLastError()) + " for input '" + InpSymbolAccountToSymbol + "' as symbol for currency conversion. " +
                                        "If you don't need any conversion, simply leave the parameter blank. The currency conversion factor is set to 1.0 -> All shown profits/losses are in the currency of the symbol." );
                        m_ConversionAcc2SymbolCurrency = 1.0;
                }                       
        }

Anyone else having some ideas, what I could do?


Cheers,

Marcel

 

I'm not sure if I can help you with the timeout problem, but one other thing in the context of your code: I guess you're looking for the conversion factor to convert from profit currency to account currency, right?

First, I assume you made sure the necessary symbol (here: EURUSD) is listed in the market overview (ctrl-m) exactly as you are trying to use it? I remember I once had a similar error when I tried to load EURUSD and in the market watch I only had the ECN symbol "EURUSD." (=in my case with a point as a suffix).

One other thing: why do you require the conversion symbol to be given as an input parameter? You can have it much easier and get the correct string (and the corresponding conversion factor) automatically:

double conversion_rate=SymbolInfoDouble(AccountInfoString(ACCOUNT_CURRENCY)+SymbolInfoString(_Symbol,SYMBOL_CURRENCY_PROFIT), SYMBOL_BID);

or, optionally, if you need to add some kind of suffix or prefix to the symbol, just add the appropriate string like so:

double conversion_rate=SymbolInfoDouble(AccountInfoString(ACCOUNT_CURRENCY)+SymbolInfoString(_Symbol,SYMBOL_CURRENCY_PROFIT)+ecn_suffix, SYMBOL_BID);

edit: or as a more complete (but also automatic) method without input parameters:

double exchange_rate=1;
string symbolstring=_Symbol;
string ecn_suffix=".";

if (SymbolInfoInteger(symbolstring,SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX || SymbolInfoInteger(symbolstring,SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX_NO_LEVERAGE)
  {
   string account_currency=AccountInfoString(ACCOUNT_CURRENCY);
   string profit_currency=SymbolInfoString(symbolstring,SYMBOL_CURRENCY_PROFIT);           
   if (account_currency!=profit_currency)
     {            
      string exchange_symbol=account_currency+profit_currency+ecn_suffix;
      exchange_rate=SymbolInfoDouble(exchange_symbol,SYMBOL_BID);
     }
  }
        

notes: for multicurrency EAs just assign whatever symbol you need to the variable "symbolstring". If your EA is single currency (or CFD), you might as well replace all "symbolstring" just by "_Symbol". And just remove the ecn suffix variable if you don't need it.

 
Marcel Fitzner:

Hi guys,

Looks like this problem can still occur. My terminal cannot run strategy simulations with the EURUSD symbol and also not with the VIX symbol.

Here an excerpt of the critical passage of my log:


As you can see, there's that timeout of exactly 10 minutes until the Strategy Tester gives up and yields no tick data.

I tried clearing the history files so the Terminal would re-download these symbols (after opening charts of EURUSD and UsaVixNov19),

but the problem still persists.


Just for the sake of completeness, here's the code how I fetch the current bid price of the EURUSD symbol:

Anyone else having some ideas, what I could do?


Cheers,

Marcel

What broker is it ? Seems like an issue to get data from the broker.
 

@Chris70: Awesome input from you. It's a much appreciated tip on how to obtain the conversion factor automatically.

@Alain Verleyen: It's ActivTrades. Interstingly, the EURUSD chart is vividly working here.

Also, please note, that my EA works properly in the live charts (e.g. Usa500, UsaTech, etc.), it's just that the Strategy Tester doesn't wanna pull the EURUSD and VIX history.


Again, great to see you looking into my issue. I'll check out the coding tips from Chris tomorrow and let you know if that helps.

 
Marcel Fitzner:

@Chris70: Awesome input from you. It's a much appreciated tip on how to obtain the conversion factor automatically.

@Alain Verleyen: It's ActivTrades. Interstingly, the EURUSD chart is vividly working here.

Also, please note, that my EA works properly in the live charts (e.g. Usa500, UsaTech, etc.), it's just that the Strategy Tester doesn't wanna pull the EURUSD and VIX history.


Again, great to see you looking into my issue. I'll check out the coding tips from Chris tomorrow and let you know if that helps.

Yes but you are requesting history data with the Strategy Tester, which is a different matter.

Try an other Access Point (broker server), on bottom right corner.

 

@Marcel: you are welcome;

btw:

- I guess you need the string for the account currency more often in your code and as it doesn't change, of course it's not necessary to repetitively check this value, so you can assign the account currency variable e.g. in OnInit() or any function that is loaded only once upon EA startup

- the reason behind the CALC_MODE check is not to reinvent the wheel for every new EA and to have a more general method that doesn't need any changes i.e. for EAs that use CFDs which usually don't require any conversion factor (so it stays 1.0).

 
Chris70:

@Marcel: you are welcome;

btw:

- I guess you need the string for the account currency more often in your code and as it doesn't change, of course it's not necessary to repetitively check this value, so you can assign the account currency variable e.g. in OnInit() or any function that is loaded only once upon EA startup

- the reason behind the CALC_MODE check is not to reinvent the wheel for every new EA and to have a more general method that doesn't need any changes i.e. for EAs that use CFDs which usually don't require any conversion factor (so it stays 1.0).

Well, I've got an explicite "TradingManager" that I instantiate once during OnInit() and which carries all relevant information as well as trading operations.

( On a site note: During all my coding, I try to follow OOP, SRP and all other good clean code principles that I know of, but sometimes I'm just silly and don't see simpler solutions. :)
  That's why I take my time to revisit all code places to see if I can find code smells and refactor them to simpler pieces.
  But in general, I am a big fan of "less is more", especially when it comes to input parameters! (As an example: One input param that really annoyed me was the Magic number so I just create a unique hash from it based on _SYMBOL and MQL_PROGRAM_NAME
)

@Alain Verleyen: The Strategy Tester keeps freezing, no matter what server I connect to... the ST unfreezes after exactly 10 minutes and produces the synchronization timeouts for the VIX symbol.

Interestingly enough though: After implementing the update from @Chris70 the EURUSD-Symbol is now being loaded properly, as you can see in the log output below.

My EA uses an indicator called OPA1-Indicator which in turn requires a VIX indicator. (On a side note: I saved a chart template under "debug.tpl" which contains this OPA1 indicator that drops -1/0/+1 signals on the Global Variables Table so the EA can pull it from there.)

VIX indicator loads history data from a symbol that does not reflect the current month (e.g. in first half of October the VIX symbol is UsaVixOct19 and in the 2nd half of Oct. it is UsaVixNov19). Since I was super annoyed by typing in this change everywhere whenever the VIX symbol changed, I implemented a utilization method to figure out this proper VIX symbol:

#include <Tools/TimeMethods.mqh>
#include <Tools/DateTime.mqh>

string DetermineVixSymbol(const string prefixVixSymbol)
{
        string vix_symbol = "";

        MqlDateTime currentDateAndTime;
        TimeToStruct(GetWinLocalDateTime(), currentDateAndTime);
        
        CDateTime dateTime;
        vix_symbol = prefixVixSymbol + dateTime.ShortMonthName(currentDateAndTime.mon + 0) + StringSubstr(IntegerToString(currentDateAndTime.year), 2);
        
        double current_vix_price = SymbolInfoDouble(vix_symbol, SYMBOL_ASK);
        
        if (!MathIsValidNumber(current_vix_price))
        {
                Print("wrong VIX symbol. Trying different month...");
                vix_symbol = prefixVixSymbol + dateTime.ShortMonthName(currentDateAndTime.mon + 1) + StringSubstr(IntegerToString(currentDateAndTime.year), 2);
                current_vix_price = SymbolInfoDouble(vix_symbol, SYMBOL_ASK);
                
                if (!MathIsValidNumber(current_vix_price))
                {
                        Print("wrong VIX symbol! Could not determine proper VIX symbol...");
                        return "";
                }
        }
        
        Print("Working VIX symbol: " + vix_symbol);
        return vix_symbol;
}

For those who are interested here is the GetWinLocalDateTime() method (obtained it from this forum here and works just fine):

#import "kernel32.dll"
int SystemTimeToFileTime(int& TimeArray[], int& FileTimeArray[]);
int FileTimeToLocalFileTime(int& FileTimeArray[], int& LocalFileTimeArray[]);
void GetSystemTime(int& TimeArray[]);
#import

datetime GetWinLocalDateTime()
{
   double hundrednSecPerSec = 10.0 * 1000000.0;
   double bit32to64 = 65536.0 * 65536.0;
   double secondsBetween1601And1970 = 11644473600.0;
   int    TimeArray[4];
   int    FileTimeArray[2];   // 100nSec since 1601/01/01 UTC
   int    LocalFileTimeArray[2];   // 100nSec since 1601/01/01 Local

   GetSystemTime(TimeArray);
   SystemTimeToFileTime(TimeArray, FileTimeArray);
   FileTimeToLocalFileTime(FileTimeArray, LocalFileTimeArray);
   
   double lfLo32 = LocalFileTimeArray[0];
   if(lfLo32 < 0)
      lfLo32 = bit32to64 + lfLo32;
   double ticksSince1601 = LocalFileTimeArray[1] * bit32to64 + lfLo32;
   double secondsSince1601 = ticksSince1601 / hundrednSecPerSec;
   double secondsSince1970 = secondsSince1601 - secondsBetween1601And1970;
   return (datetime)secondsSince1970;
}


I suspect the real problem for the Strategy Tester is the dll import. Usually we have that dialog popping up when pulling an EA/indicator with such dll requirements into the chart - and also when debugging with live data, but NOT with historical data!


So maybe I need to avoid loading dlls for ST simulations and define the VIX symbol via classic input parameters?

 

Hhmmmmmmmm, jap. That was indeed the problem. I just fed my VIX indicator with a manual input parameter and the Strategy Tester is running properly..  

// VixIndiator.mq5

sinput string                           VixSymbol = "UsaVixNov19";
// ...

int OnInit()
{
        LogPrefix = "[VIX-Indicator:] ";
        
        chartPeriod = Period();
        
        m_StratTesterRunning = IsTester() || IsOptimization();
        
        if (m_StratTesterRunning) {
                vixChartSymbol = VixSymbol;
        } else if (SuffixDate == MMMYY) {
                vixChartSymbol = DetermineVixSymbol(VixSymbol);
        }
   //....
}
Reason: