Unisciti alla nostra fan page
MQL Plus Enhanced Error Handler Support - libreria per MetaTrader 5
- Visualizzazioni:
- 3400
- Valutazioni:
- Pubblicato:
- 2020.11.22 11:47
- Aggiornato:
- 2023.05.14 13:22
- Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance
Change-Log 4.2
- Bugfixes, compatibilitishues resolved.
- Fixed error in UserErrorHandler function signature.
Change-Log 4.0
- Recreated the whole code structure to support shared library compilation as wel las header include compilation
- Supports external CSV-File as supply for mql error codes
- Is MQL4 compatible
- All MQL4 and MQL5 Languages are included
- Supports MQL API function shadowing to be turned on or off
From now on the project is distributed as shared project over MQL cloud storage. You are welcome to contribute to the code.
You will need "MQLplus Include Library Collection" Project. optionally add the "MQLplus Enhanced Error Handler Library" Project to your files to have the shared binary library compiled as well as get an example project, showing the usage of the library.
Change-Log 3.12
- Massive improvements to all aspects of the errror code generation and handling
- Compatibility with MQL4 integrated
- Support for user supplied OnError() function definition, see beginning of lib_error.mql-file
- Overwrite Built-In function SetUserError()
- Translation of error messages to almost all supported languages by MQL
Current Version 3.12
Encapsulates error code and text handling.
Supported features:
- User defined error codes
- Error code groups
- Customizable output string
- Seemless integration
Error code handling and error code resolving to text messages is a pain. This include file will solve some of the daily issues of handling error codes.
Example output:
This output was produced by ObjectGetInteger() in exaple code below.
Example code:
///////////////////////////////////////// // // Handle user specified warning codes // as errors. // #define LIB_ERR_LEVEL_WARNING_AS_ERROR #include <mqlplus/lib_error.mqh> /* ********************************************************************************************************* * Provider return codes * ********************************************************************************************************* */ // Define error group id #define EA_ERRGROUP_CODE_EA_CORE 0x01 // Defined return codes #define CORE_SUCCESS LIB_ERROR_CODE(EA_ERRGROUP_CODE_EA_CORE, 0x00) #define CORE_INFO_CORE_READY LIB_ERROR_CODE_HANDLED(EA_ERRGROUP_CODE_EA_CORE, 0x01) #define CORE_WARN_PENDING_OPERATION LIB_ERROR_CODE_WARNING(EA_ERRGROUP_CODE_EA_CORE, 0x01) // Define message resolver LIB_ERR_REGISTER_RESOLVER_BEGIN(EA_ERRGROUP_CODE_EA_CORE) LIB_ERR_REGISTER_RESOLVER_MSGCODE(CORE_SUCCESS, "CORE_SUCCESS", "Operation success. An order has been processed.") LIB_ERR_REGISTER_RESOLVER_MSGCODE(CORE_INFO_CORE_READY, "CORE_INFO_CORE_READY", "Expert advisor: Core ready.") LIB_ERR_REGISTER_RESOLVER_MSGCODE(CORE_WARN_PENDING_OPERATION, "CORE_WARN_PENDING_OPERATION", "A pending operation is awaiting confirmation.") LIB_ERR_REGISTER_RESOLVER_END(EA_ERRGROUP_CODE_EA_CORE) //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- // Set a user defined error code SetUserError(CORE_INFO_CORE_READY); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- // Perform some check check_for_pending_orders(); // Retrieve error code and display its text OnError(); //--- return; } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- // Retrieve the error code int err_code = NULL; // Update some state by function if( (!some_function()) && (OnError(err_code)) ) // Display error message in journal and retrieve its corresponding error number { // Last error code is saved in err_code return; } // Continue processing //--- return; } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| check_for_pending_orders() | //+------------------------------------------------------------------+ void check_for_pending_orders() { //--- // Set a user defined error code SetUserError(CORE_WARN_PENDING_OPERATION); //--- return; } //+------------------------------------------------------------------+ //| some_function() | //+------------------------------------------------------------------+ bool some_function() { //--- // Error status bool err = false; // Perform some eventually failing operation err |= (!err) && !ObjectGetInteger(ChartID(), "", OBJPROP_COLOR) && OnError(__LINE__); // Set a user defined error code err |= (!err) && SetUserError(CORE_SUCCESS); //--- return(!err); }
Indicator Camarilla Points "Stocks & Commodities V. 31:3 (pg. 10-15)"
MQL Plus Enhanced Debugging SupportAn (optional) include file to enhance debugging experience.
Doulble MA Cross Draw Histogram MT5
state - behavioral design patternallow an object to alter its behavior when its internal state changes. the object will appear to change its class