Hello,
is there any way to catch an error?
Since there is no try..catch mechanism in mql5, a program will crash upon creating an error.
This seems to be a major design flaw in the mql5 language. Once the program detects an error it knows it will deliberately crash. One can try to miminize damage by closing some position or something along the lines, but the program will crash no matter what.
Is there any way to circumvent this?
While a try/catch mechanism to handle errors would be useful, there is other way to manage errors and there is no design flaw at all.
Your question is too vague, you can use GetLastError() function and most of built-in functions return a code to check if there was an error or not.
There is only a few errors which lead to program crash.
While a try/catch mechanism to handle errors would be useful, there is other way to manage errors and there is no design flaw at all.
Your question is too vague, you can use GetLastError() function and most of built-in functions return a code to check if there was an error or not.
There is only a few errors which lead to program crash.
Thanks for your answer. Yes, many functions can be checked for an error. But there are some functions that cannot be checked, and there is no way to get rid of the error in that case.
For example: When looping over all available symbols (via loop over SymbolsTotal(false)) there seem to be some erroneous Symbols. While it's no problem to get the Symbol name via SymbolName(), SymbolInfoString() causes an error 4301 "Unknown Symbol". That seems to cause a crash of the EA.
However this might also be a problem with the strategy tester. The problem does not appear when livetesting the EA.
you dont do loops over symbolstotal false only over symbolstotal true.
when you do a loop over symbolstotal false you try to work with none existent symbols.
this is a serious flaw indeed, but it's not metatraders, it's your personal flaw.
you dont do loops over symbolstotal false only over symbolstotal true.
when you do a loop over symbolstotal false you try to work with none existent symbols.
this is a serious flaw indeed, but it's not metatraders, it's your personal flaw.
That is simply wrong. SymbolsTotal(true) returns only symbols in Market Watch. SymbolsTotal(false) should return the total number of symbols. This is stated very clearly.
The problem only appears in Strategy Tester, and is caused by an error with history syncronization.
On Metaquotes-Demo as Server this problem can be easily reproduced, try it for yourself.
- www.mql5.com
it is not wrong you can only work with symbolstotal true in matketwatch.
all other symbols you encounter in symbolstotal false are unsupported.
this is what causes this problem.
it's bad coding practice on your side.
there is no feed for those symbols there is no use in working with them.
i do not have to reproduce this because it is useless coding.
Hello,
is there any way to catch an error?
Since there is no try..catch mechanism in mql5, a program will crash upon creating an error.
This seems to be a major design flaw in the mql5 language. Once the program detects an error it knows it will deliberately crash. One can try to miminize damage by closing some position or something along the lines, but the program will crash no matter what.
Is there any way to circumvent this?
Please don't double topic.
This problem arises when you are tring to acces data's on symbol not selected in Market Watch.
string thisSymbolPath=SymbolInfoString(thisSymbolName,SYMBOL_PATH);
The Strategy Tester then try to download history data for the symbol, but it's not selected in Market Watch and it fails.
What is the point to run such code with the Strategy Tester ?
Sorry for the double topic.
It does not seem to matter if a symbol is selected into Market Watch for history download. It works for most symbols.
In fact the issue went away somehow. I ran the exact same program today and there were no issues.
What I am aware of now, is that I should select all symbols into Market Watch when working with them, I oversaw that before.
Also I should better use the bool-type functions:
if(!SymbolSelect(thisSymbolName,true))Print("Select went wrong!"); if(!SymbolInfoString(thisSymbolName,SYMBOL_PATH,thisSymbolPath))Print("Error getting path!");
like you told me.
Sadly the code without SymbolSelect()and with string-type functions runs just fine now, so I cannot try if the measures would have prevented the error.
One of the erroneous symbols was called "Dividend", it seems to have disappeared now.
The use of such a program is for example calculation of correlations between different symbols. Since there is no way (or is there?) to loop only over forex symbols, there must be a loop over all symbols.
Thanks for your help!
no because when you add a symbol that has no tick feed you can not use it.
if you want to loop over forex only symbols you compare the symbols you want to use in the loop itself.
no because when you add a symbol that has no tick feed you can not use it.
if you want to loop over forex only symbols you compare the symbols you want to use in the loop itself.
I don't understand what you mean. Can you elaborate? What do you mean with tick feed? What is the purpose of symbols without a tick feed?
I also don't get what you mean with comparing the symbols in the loop itself. You mean I should still loop from 0 to Symbolstotal(false)? As soon as I get the name of the symbols, every symbol's history will be downloaded. Currently I am using the symbol's path (i.e. "forex/EURUSD" or "metals/GOLD") to decide if it's a forex symbol or not.
the purpose of symbols without a tick feed is for you to do a scan over symbolstotal false, to get an error, because there is no tick feed,
no i do not mean you do a scan over symbols total false you never do a scan over sysmbols total false you only do a scan over symbols total true because then you can be sure there will be a active tick feed for all those symbols.
what i mean is that you compare to filter the symbols you want to use.
you will get it eventually.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
is there any way to catch an error?
Since there is no try..catch mechanism in mql5, a program will crash upon creating an error.
This seems to be a major design flaw in the mql5 language. Once the program detects an error it knows it will deliberately crash. One can try to miminize damage by closing some position or something along the lines, but the program will crash no matter what.
Is there any way to circumvent this?