Current Version 1.00
Encapsulates error code and text handling.
Supported features:
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 code:
//*********************************************************************************************************************************************************/ // Return codes // /////////////////////////////////////// // // Define error group id // This ID must be unique within // the given project. // // Valid values for Group ID are // between 0x00 and 0xEF // 0xF0 to 0xFF is reserved. // // Error codes categories // 0x00 = Succes // 0x01 ... 0xDF = Errors, // 0xE0 ... 0xEF = Warnings // 0xF0 ... 0xFF = Handled Errors // #define EA_ERRGROUP_CODE_SIG_GENERATOR 0x01 // Define internal set codes #define _SIG_SUCCESS LIB_ERROR_CODE(EA_ERRGROUP_CODE_SIG_GENERATOR, 0x00) #define _SIG_ERR_INVALID_VALUE LIB_ERROR_CODE(EA_ERRGROUP_CODE_SIG_GENERATOR, 0x01) #define _SIG_ERR_CREATE_SIGNAL LIB_ERROR_CODE(EA_ERRGROUP_CODE_SIG_GENERATOR, 0x02) #define _SIG_ERR_INVALID_SYMBOL LIB_ERROR_CODE(EA_ERRGROUP_CODE_SIG_GENERATOR, 0x03) #define _SIG_ERR_INDICATOR LIB_ERROR_CODE(EA_ERRGROUP_CODE_SIG_GENERATOR, 0x04) // Define global return codes #define SIG_SUCCESS LIB_ERROR_CODE_EXPORT(_SIG_SUCCESS) #define SIG_ERR_INVALID_VALUE LIB_ERROR_CODE_EXPORT(_SIG_ERR_INVALID_VALUE) #define SIG_ERR_CREATE_SIGNAL LIB_ERROR_CODE_EXPORT(_SIG_ERR_CREATE_SIGNAL) #define SIG_ERR_INVALID_SYMBOL LIB_ERROR_CODE_EXPORT(_SIG_ERR_INVALID_SYMBOL) #define SIG_ERR_INDICATOR LIB_ERROR_CODE_EXPORT(_SIG_ERR_INDICATOR) // Define message resolver LIB_ERR_REGISTER_RESOLVER_BEGIN(EA_ERRGROUP_CODE_SIG_GENERATOR) LIB_ERR_REGISTER_RESOLVER_MSGCODE(SIG_SUCCESS, "Operation success. All values could be calculated within given parameters.") LIB_ERR_REGISTER_RESOLVER_MSGCODE(SIG_ERR_INVALID_VALUE, "Operation aborted. Invalid function input.") LIB_ERR_REGISTER_RESOLVER_MSGCODE(SIG_ERR_CREATE_SIGNAL, "Operation failed. Unable to create signal.") LIB_ERR_REGISTER_RESOLVER_MSGCODE(SIG_ERR_INVALID_SYMBOL, "Operation failed. Invalid symbol specified.") LIB_ERR_REGISTER_RESOLVER_MSGCODE(SIG_ERR_INDICATOR, "Operation failed. Indicator could not be created.") LIB_ERR_REGISTER_RESOLVER_END(EA_ERRGROUP_CODE_SIG_GENERATOR) // // END Return codes //*********************************************************************************************************************************************************/ bool CalcInit() { // Ichimoku Kinju Sen // Create baseline indicator hBL = iIchimoku(fw_cfg::CustomSymbol, fw_cfg::CustomTimeframe, 9, BasePeriods, 52); if(hBL == INVALID_HANDLE) { // Set the internal error code (Using underscore to distinguish between set and retrieve error code) err_SetUserError(_SIG_ERR_INDICATOR, "symbol = " + fw_cfg::CustomSymbol); return(false); } // Configure baseline buffer nBLbuffer = 1; // Return return(true); } void do_calc() { // User defined error codes if(!CalcInit()) { string error_msg = err_ResolveLastError(); // ... OR ... printf(err_ResolveLastError()); } // MQL error codes if(CopyBuffer() == -1) { string error_msg = err_ResolveLastError(); // ... OR ... // See doc for options on calling this function printf(err_ResolveLastError()); } // Return return; }
Indicator Camarilla Points "Stocks & Commodities V. 31:3 (pg. 10-15)"
An (optional) include file to enhance debugging experience.
Doulble MA Cross Draw Histogram MT5
allow an object to alter its behavior when its internal state changes. the object will appear to change its class