Hi everyone, I ran into quite a perplexing problem today. There are many symbols that I cannot select or get information from in my EA. In fact, it seems as if there's a bug within MQL4 itself.
The following EA provides different results when ran in the debugger vs a strategy tester (both using the GBPCAD chart).
int OnInit(){
if (!SymbolSelect("USDCAD", true))
Print("Couldn't select USDCAD");
if (SymbolInfoInteger("USDCAD", SYMBOL_VISIBLE))
Print("USDCAD visible");
elsePrint("USDCAD isn't visible");
double e;
if (SymbolInfoDouble("USDCAD", SYMBOL_ASK, e))
Print("It worked");
elsePrint("It didn't work, ", GetLastError());
return(INIT_SUCCEEDED);
}
On the debugger in live data, the following is printed:
2020.08.23 11:26:01.2002017.02.09 00:00:00 Exit Backtester GBPCAD,Daily: It didn't work, 4106
Where error code 4106, according to the documentation, states that the symbol is not selected in Market Watch or found in the list of "available ones".
However, running the following code:
void PrintSymbols(){
for (int i = 0; i < SymbolsTotal(true); ++i){
Print(i, " ", SymbolName(i, true));
}
}
intOnInit(){
PrintSymbols();
return(INIT_SUCCEEDED);
}
Prints the same results in both cases, among them being USDCAD:
So SymbolName proves that USDCAD is available, while SymbolSelect, SymbolInfoInteger, and SymbolInfoDouble prove otherwise.
Why is this the case? I'm attempting to automatically buy and sell in my EA, and it's important that I'm able to get symbol info from other symbols to calculate the correct amount of lots I need. This doesn't seem to be possible inside the strategy tester.
2. Returns true or false depending on whether a function is successfully performed. In case of success, the value of the property is placed into a recipient variable, passed by reference by the last parameter. It is recommended to use SymbolInfoTick() if the function is used for getting information about the last tick. It may well be that not a...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi everyone, I ran into quite a perplexing problem today. There are many symbols that I cannot select or get information from in my EA. In fact, it seems as if there's a bug within MQL4 itself.
The following EA provides different results when ran in the debugger vs a strategy tester (both using the GBPCAD chart).
int OnInit(){ if (!SymbolSelect("USDCAD", true)) Print("Couldn't select USDCAD"); if (SymbolInfoInteger("USDCAD", SYMBOL_VISIBLE)) Print("USDCAD visible"); else Print("USDCAD isn't visible"); double e; if (SymbolInfoDouble("USDCAD", SYMBOL_ASK, e)) Print("It worked"); else Print("It didn't work, ", GetLastError()); return(INIT_SUCCEEDED); }On the debugger in live data, the following is printed:
2020.08.23 11:25:20.011 Exit Backtester GBPCAD,Daily: USDCAD visible
2020.08.23 11:25:20.011 Exit Backtester GBPCAD,Daily: It worked
On the strategy tester near the beginning of 2017, the following is printed:
2020.08.23 11:26:01.200 2017.02.09 00:00:00 Exit Backtester GBPCAD,Daily: Couldn't select USDCAD
2020.08.23 11:26:01.200 2017.02.09 00:00:00 Exit Backtester GBPCAD,Daily: USDCAD isn't visible
2020.08.23 11:26:01.200 2017.02.09 00:00:00 Exit Backtester GBPCAD,Daily: It didn't work, 4106
Where error code 4106, according to the documentation, states that the symbol is not selected in Market Watch or found in the list of "available ones".
However, running the following code:
2020.08.23 11:38:03.235 Exit Backtester GBPCAD,Daily: 18 USDCAD
So SymbolName proves that USDCAD is available, while SymbolSelect, SymbolInfoInteger, and SymbolInfoDouble prove otherwise.
Why is this the case? I'm attempting to automatically buy and sell in my EA, and it's important that I'm able to get symbol info from other symbols to calculate the correct amount of lots I need. This doesn't seem to be possible inside the strategy tester.