try this, it will print out only new error if it occurred
int n_err=GetLastError(); if(n_err && n_err!=v_err) { v_err = n_err; Print(n_err); ResetLastError(); }
THANK YOU! That worked. but I still don't understand what my failure was... is there some kind of errata?
edit: what if there is the same error multiple times after one another. I want the "new" errors to be shown.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi there,
at the end of my EA's OnTick() function I wrote a short line to get the latest error that occured:
Although I am resetting it, on every tick there will be printed an error until there is a new one with another Error-Code. In my case there occurs an error 4756 due to market closed and it will be printed every new bar... How do I manage to get it printed only ONCE after it occured? I have tried to store it in a variable, but that got no relief at all :-(
edit: v_err is defined as a global variable of integer type