Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 845

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
Pokrov, I told you what you're looking at...
Here is the answerhttps://www.mql5.com/ru/forum/131277/page295#455199
Thanks to the author.
Can you tell me if the error handling block below is spelled correctly or if there's something wrong? Don't swear right away ))))
How can the indicator save the value history to a file (and load it later)? Are there any ready-made solutions?
Can you tell me if the error handling block below is spelled correctly or if there is something wrong? Don't swear right away ))))
In my opinion, error handling should be in the form of a user-defined function, which should be called after any action involving access to the server.
For example OrderSend() returns order ticket or -1 in case of failure, i.e. in case of error. So, it's necessary to call the error handler in case of unsuccessful command execution and pass the error code into it. And in the error handler, we should provide a return value at which the failed action is repeated or at another value it is stopped.
For example the prices have changed, RefreshRates(); and try again, and if there is not enough money it is probably better to stop trying.
In my opinion, error handling should be in the form of a user-defined function, which should be called after any action related to server access.
For example OrderSend() returns order ticket or -1 in case of failure, i.e. in case of error. So, you should call the error handler in case of unsuccessful command execution and pass the error code into it. And in the error handler, we should provide a return value at which the failed action is repeated or at another value it is stopped.
For example the prices have changed, RefreshRates(); and retry, and in case of insufficient funds it is probably better to stop trying.
I have functions after GetLastError and if there is an error, won't it go to this block (as written) and commands won't be executed? I understand the chain, e.g. OrderSend() -> GetLastError -> error block Sleep(3000) RefreshRates() -> exit the block and if conditions remain OrderSend() is requested again. Or my reasoning and concepts are wrong. I understand you want to write the return value 1 or 0 in the block, but my functions are simple not related to boolean values like SignalBuy, if I understand correctly, the return values should be returned there.
I have GetLastError after functions and if an error occurs, won't it go to this block (as written) and commands won't be executed? I understand the chain, e.g. OrderSend() -> GetLastError -> error block Sleep(3000) RefreshRates() -> exit the block and if conditions remain OrderSend() is requested again. Or my reasoning and concepts are wrong. I understand you want to write the return value 1 or 0 in the block, but my functions are simple not related to boolean values like SignalBuy, if I understand correctly, the return values should be returned there.