//+------------------------------------------------------------------+ //| Errors.mqh | //+------------------------------------------------------------------+ //| Copyright 2014, Bear Naked Forex | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, Bear Naked Forex" #property strict //+-------------------------------------------------------------------+ //| Function Name: CBNForexFunctions. | //| Description: All Indicators EAs and Scripts can call these | //| | //+-------------------------------------------------------------------+ #include <\FATTools Type cast\CBNForexFunctions.mqh> //+------------------------------------------------------------------+ //| Status Table: | //| Alpha Function 1.00.A | //| Beta Function 1.00.B | //| Released Function 1.00.R | //| Hardened Function 1.00.H | //+------------------------------------------------------------------+--------------------+ //| Function Name: CBNForexFunctions. | //| Description: All Indicators EAs and Scripts can call these | //| | //+-------------------------------------------------------------------+ //| | //| Function Name: vErrorHub.. | //| | //+-------------------------------------------------------------------+ void CBNForexFunctions::vErrorHub(int iParamError, int iParamFunc) { //+-------------------------------------------------------------------+ //| Initialization of Function | //+-------------------------------------------------------------------+ //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ int iTemporaryError = 0; int iError = mcaGOD[ iParamFunc ].iError; int iPrevError = mcaGOD[ iParamFunc ].iPrevError; int iRetryCount = mcaGOD[ iParamFunc ].iRetryCount; int iUserError = iParamError - (65536*2); string sRecordThis = "" ; string sErrorCode = "" ; if( mcaGOD[ iParamFunc ].iError > 65536 ) mcaGOD[ iParamFunc ].iError = iUserError; //+-------------------------------------------------------------------+ //| Main Body | //+-------------------------------------------------------------------+ if( iError != 0 && iError != NULL ) { vSetStallKillWait(iError, iParamFunc); vSetLevel(iError,iParamFunc); //+-------------------------------------------------------------------+ //| Stall Kill or Wait on error | //| What is the error in english | //| send error 2 screen | //+-------------------------------------------------------------------+ if( iParamError < 65536 && iParamError>0 ) { sRecordThis = sMetatraderErrorDescription( iParamError, iParamFunc); } //+-------------------------------------------------------------------+ //| DEVELOPER ERRORS //| Stall Kill or Wait on error | //| What is the error in english | //| send error 2 screen | //+-------------------------------------------------------------------+ if( iParamError < 0 ) { sRecordThis = sDevDefinedErrorDescription( iParamError, iParamFunc); } mcaGOD[ iParamFunc ].sError = sRecordThis; } //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ vErrorLog(); //+----- End God } //+-------------------------------------------------------------------+ //|bSetErrorClearError| //| Function Name: vSetErrorClearError.. | //| | //+-------------------------------------------------------------------+ bool CBNForexFunctions::bSetErrorClearError( int iParamError,int iParamFunc, string sParamFunction, string sParamPath , int iParamLine = 0 ) { //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ bool bRetunThis = true; datetime dtTimeofError = TimeCurrent(); int z = 0; int iFunc = piFunc; int iUserError = iParamError - (65536*2); //+-------------------------------------------------------------------+ //| Main Body | //+-------------------------------------------------------------------+ if( piFunc == 0 || iParamFunc == 0 ) iFunc = z; vOrderGod(piFunc , sParamFunction); if( iParamError != 0 ) { mcaGOD[ iFunc ].sPrevErrOccurredIn = mcaGOD[ iFunc ].sFutErrOccurredIn ; mcaGOD[ iFunc ].iPrevError = mcaGOD[ iFunc ].iErrorFutNum ; mcaGOD[ iFunc ].sPrevComOut = mcaGOD[ iFunc ].sComOut ; mcaGOD[ iFunc ].bSetErrorInFunction = true;; mcaGOD[ iFunc ].sFutErrOccurredIn = sParamFunction ; mcaGOD[ iFunc ].iError = iParamError; mcaGOD[ iFunc ].iErrorFutNum = iFunc; mcaGOD[ iFunc ].dtTimeofError = dtTimeofError; mcaGOD[ iFunc ].iNumberOfTimes++; if( mcaGOD[ iFunc ].iError > 65536 ) mcaGOD[ iFunc ].iError = iUserError; //+----- get function info and error vErrorHub(iParamError, iParamFunc); } switch(iParamError ) { case 4066: if(bError4066()) iParamError = 0; break; case 4073: if(bError4073()) iParamError = 0; break; case 4200: iParamError = 0; break; //+----- may already exist case 4059: iParamError = 0; break; case 4000: iParamError = 0; break; } //+---- Turn logging if( iParamError != 0 ) vDumpStackSQL(); //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ if(iParamError != 0) bRetunThis = True; else bRetunThis = false; return(bRetunThis); } //+-------------------------------------------------------------------+ //| | //| Function Name: vSetStallKillWait.. | //| | //+-------------------------------------------------------------------+ void CBNForexFunctions::vSetStallKillWait(int iParamError , int iParamFunc ) { //+-------------------------------------------------------------------+ //| Stall Kill or Wait on error | //| What is the error in english | //| send error 2 screen | //+-------------------------------------------------------------------+ switch(iParamError ) { case 4066: if(bError4066()) iParamError = 0; return;break; case 4073: if(bError4073()) iParamError = 0; return;break; } if( iParamError < 65536 ) { vSetMetatraderStallKillWait( iParamError,iParamFunc ); } //+-------------------------------------------------------------------+ //| DEVELOPER ERRORS //| Stall Kill or Wait on error | //| What is the error in english | //| send error 2 screen | //+-------------------------------------------------------------------+ if( iParamError > 65536 ) { vDevDefinedStallKillWait(iParamError); } } //+-------------------------------------------------------------------+ //| | //| Function Name: vDevDefinedStallKillWait.. | //| | //+-------------------------------------------------------------------+ void CBNForexFunctions::vDevDefinedStallKillWait( int iParamErrorCode ) { //+-------------------------------------------------------------------+ //| Initialization of Function | //+-------------------------------------------------------------------+ if(menTradingStatus == ENUM_SIGNAL_DISABLE ) return; //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ //+----- iFunctionKey = 0 miSEIKey is 1 - 3 //+---- 000 miEANumber 170 - 199 //+---- 00 miFileNumber 1 - 34 //+---- 0000 miFunctionNumber 1 - 410 //+----- 000 miFunctionRow 1 - 999 //+-------------------------------------------------------------------+ //| Main Body | //+-------------------------------------------------------------------+ int iSwitchNumber = iParamErrorCode - (65536*2); switch( iSwitchNumber) { //+------------------------------------------------------------------+ //| User Input errors | //+------------------------------------------------------------------+ //+---- u - User error //+---- m - metatrader //+---- d - Desk errors //+---- p - Programer //+---- s - scanning not critical no fail case eruNoCMD: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruNoLots: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruNoEPrice: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruNoSPrice: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruNoTPrice: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruNoExp: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruMaxLossOpen: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruEAInstance: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruNoSymbol: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdMargin: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruEmail: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruMaxLossClosed: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruTradingAllowed: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruDllChecked: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdFifoFailedClose: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpDisableEA: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpStallEA: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruEaAuth: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruEaWrongTF: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruAlreadyRunning: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case eruNoTrend: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+------------------------------------------------------------------+ //| Developer errors | //+------------------------------------------------------------------+ //+---- u - User error //+---- m - metatrader //+---- d - Desk errors //+---- p - Programer //+---- s - scanning not critical no fail case erpTradeLocked: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpPatternLocked: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpPivotLocked: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpSQLLocked: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpCorrelationLocked: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpSTW: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOverUnder: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpPipe: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermData: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpConnect: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpLocalInt: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpPivot: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpGidFailed: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpFailedGMT: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpDiabled: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpFiveTimes: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpNoStopLoss: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpUnable2Load: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+-------------------------------+ //| Developer errors for Sql | //+-------------------------------+ //+---- u - User error //+---- m - metatrader //+---- d - Desk errors //+---- p - Programer //+---- s - scanning not critical no fail case erpNoSqlArray: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpSqlInt: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpSqlQuery: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpSqlInsert: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpSqlUpdate: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpSqlDelete: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+-------------------------------+ //| Developer errors for Orders | //+-------------------------------+ //+---- u - User error //+---- m - metatrader //+---- d - scanning //+---- s - Desk errors //+---- p - Desk errors //+---- s - scanning not critical no fail case erpOrderSendOk: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderModify: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderSelect: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderSelectCMD: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderSelectSYM: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderSelectEA: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderSelectDT: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderDelete: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderClose: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpOrderMod : menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erp2Close2Change: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erpNoMNumber: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+-------------------------------+ //| Desk Errors | //+-------------------------------+ //+---- u - User error //+---- m - metatrader //+---- d - scanning //+---- s - Desk errors //+---- p - Desk errors //+---- s - scanning not critical no fail case erdAllowed: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdLotsStep: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdSTMDISABLED: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdSTMSHORTONLY: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdSTMLONGONLY: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdSTMCLOSENLY: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdMinL: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdMaxL: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdTarget: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdStop: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdWebUTC: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case erdSymbol: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+-------------------------------+ //| Metatrader Errors | //+-------------------------------+ //+---- u - User error //+---- m - metatrader //+---- d - scanning //+---- s - Desk errors //+---- p - Desk errors //+---- s - scanning not critical no fail case ermVersion: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermSync: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermRates: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermMoreData: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermDataZero: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermDataBad: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermNoZeroBidAsk: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermQTime: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ermAllocateMem: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+------------------------------------------------------------------+ //| Scanning is just stopped | //+------------------------------------------------------------------+ //+---- u - User error //+---- m - metatrader //+---- d - scanning //+---- s - Desk errors //+---- p - Desk errors //+---- s - scanning not critical no fail case ersTimeHM: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent() ; break; case ersTimeDay: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent() ; break; case ersTBetweenT: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ersTBetweenE: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ersMaxTrades: break; case ersSpread: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ersMaxLots: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent();break; case ersMaxL : menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent();break; case ersMaxDelta: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent() ; break; case ersHVCheck: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent() ; break; case ersNews: break; case ersFailedTrend: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent() ; break; case ersNoSpread: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; case ersHVATR: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent() ; break; case ersNoBox: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent() ; break; case ersSpreadTPSL: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; } //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ } //+-------------------------------------------------------------------+ //| | //| Function Name: sDevDefinedErrorDescription.. | //| | //+-------------------------------------------------------------------+ string CBNForexFunctions::sDevDefinedErrorDescription(int iParamErrorCode , int iParamFunc) { //+-------------------------------------------------------------------+ //| Gobal Operation's Initialization | //+-------------------------------------------------------------------+ //+----- Gobal Operation Flow Tracking vGOperationIntArray(__FUNCTION__,__PATH__,__FUNCSIG__); int iFunc = piFunc; string sGod[]; //+----- Stack Control of Errors Initialization vGOperationIn(__FUNCTION__,__PATH__,sGod); //+-------------------------------------------------------------------+ //| Initialization of Function | //+-------------------------------------------------------------------+ //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ datetime dtTimeCurrent = dtGetTimeCurrent(); int iError = 0; int iClosingHour = mcaUI[ miEANumber ].iTimeEnd; int iOpeningHour = mcaUI[ miEANumber ].iTimeStart; int iUserError = iParamErrorCode - (65536*2); int iDayofWeek = TimeDayOfWeek(dtTimeCurrent); int iTemporaryError = 0; string sTimeBError = sI2S(mcaUI[ miEANumber ].iTimeBError); string sTimeBTrades = sI2S(mcaUI[ miEANumber ].iTimeBTrades); string sFileName = mcaGOD[ iParamFunc ].sFileName; string sClosingHour = sI2S(iClosingHour); string sOpeningHour = sI2S(iOpeningHour); string sMaxLotsPTrade = DoubleToStr(mcaUI[ miEANumber ].dMaxLotsPTrade, 2); string sAccountNumber = sI2S(AccountNumber()); string sAccountServer = AccountInfoString(ACCOUNT_SERVER); string sTimeCurrent = sDT2S(dtGetTimeCurrent()); string sCyclesGL = sI2S(iCycletoPrint ()); string sBugTicketNumber = sI2S( mcaOrders[ miS ].iOrderTicket); string sLots = sD2S(mcaOrders[ miS ].dOrderLots,2); string sRiskToTrade = sD2S(mcaOrders[ miS ].dRiskOnAccount,7); string sTerminalInfoInteger = sI2S(TerminalInfoInteger(TERMINAL_BUILD)); string sTerminal_Build_Complied_Too = mcaGOD[ iParamFunc ].sBuildNumberDrive; string sNumberOfWin = sI2S(miOutSide_Stall_After_NumberOfWin) ; string sNumberofLoss = sI2S(miOutSide_Stall_After_NumberOfLoss); string sMazLossTotal = sD2S(mcaUI[ miEANumber ].dMazLossTotal,2); string sRetunThis = "" ; string sReprocess = ""; string sMaxLots = DoubleToStr((mstOpenTrade.dLots_Delta + mcaOrders[ miS ].dOrderLots),0); string sTimeFrame = sTimeFrameIntToName(miEATimeFrame); string sFutName = mcaGOD[ iParamFunc ].sFutName; string sCompanyName = TerminalCompany(); string sStartEndTime = "The Ea is Set to start at "+ sOpeningHour+" GMT and stop trading at "+ sClosingHour+" GMT"; string sDisplayMessage = ""; string sError = mcaGOD[ iParamFunc ].sError; string sFilePath = mcaGOD[ iParamFunc ].sFilePath; mdtLastQuote = (datetime)SymbolInfoInteger(msEASymbol,SYMBOL_TIME)-1000; //+-------------------------------------------------------------------+ //| Main Body | //+-------------------------------------------------------------------+ if(iDayofWeek == 5 ) { iClosingHour = mcaUI[ miEANumber ].iTimeEndTGIF; iOpeningHour = mcaUI[ miEANumber ].iTimeStartTGIF;} if( iClosingHour > iOpeningHour) sStartEndTime = "The Ea is Set to start at "+ sI2S(iOpeningHour)+" GMT and stop trading at "+ sI2S(iClosingHour)+" GMT the next Day"; if( iParamErrorCode > 65536 ) iError = iUserError; if( iParamErrorCode < 0 ) iError = iParamErrorCode; switch(iError ) { //+------------------------------------------------------------------+ //| User Input errors | //+------------------------------------------------------------------+ //+---- u - User error Example no CMD //+---- m - Metatrader Example no rates //+---- s - Scanning Example Spread to wide Temporary //+---- d - Desk errors Example check can I trade //+---- p - Programer No Need for Example case eruNoCMD: sRetunThis = msEAName + " has not been configured correctly and is unable to tell what the Direction has been picked. Please reconfigure. "; break; break; case eruNoLots: sRetunThis = msEAName + " has not been configured correctly and is unable to tell what the lot size of the trade. Please reconfigure. "; break; case eruNoEPrice: sRetunThis = msEAName + " has not been configured correctly and is unable to tell what price to place the trade at. Please reconfigure. "; break; case eruNoSPrice: sRetunThis = msEAName + " has not been configured correctly and is unable to tell what price to place the stop at. Please reconfigure. "; break; case eruNoTPrice: sRetunThis = msEAName + " has not been configured correctly and is unable to tell what price to place the target at. Please reconfigure. "; break; case eruNoExp: sRetunThis = msEAName + " has not been configured correctly and is unable to tell when the pending order with no Expiration date. Please reconfigure. "; break; case erdMargin: sRetunThis = msEASymbol + " Has Lost (X) number of times in a row: " + sCyclesGL + " The Current Lot Size is " + sLots + " Run out of Margin Lowered Lot sizes " + "\n\n"; break ; case eruMaxLossOpen: sRetunThis = msEAName + " has reached a max loss amount of $"+sMazLossTotal; break ; case eruEAInstance: sRetunThis = "Another Ea may be running Please check. "; break; case eruNoSymbol: sRetunThis = msEAName + " has not been configured correctly and is unable to tell which symbol to trade. Please reconfigure. "; break; case eruDllChecked: sRetunThis = "Allow DLL imports has not been checked"; break; case eruMaxLossClosed: sRetunThis = "The account has a Drawn down " +sMazLossTotal + " Currently account equity is " + DoubleToStr(AccountEquity(), 2) ; break; case eruTradingAllowed: sRetunThis = "Allow Live trading Not Checked"; break; case erdFifoFailedClose: sRetunThis = "The Government is Not allowing you to close order ticket number "+sBugTicketNumber +"For account number "+sAccountNumber+" On server. "+sAccountServer;break ; case erpStallEA: sRetunThis = "The "+msEAName+" was Stalled by user "; break; case eruEaAuth: sRetunThis = "Please Authenticate Account Number "+sAccountNumber; vDrawOne( sRetunThis); vDrawOne(sRetunThis); break; case eruEaWrongTF: sRetunThis = "This "+msEAName+" will not run on this time frame "+sTimeFrame+" Time Fraame";; break; case eruAlreadyRunning: sRetunThis = "The "+msEAName+"EA is already Running. try removing the global variables ";vDrawOne(sRetunThis); break; case eruNoTrend: sRetunThis = msEAName + " has not been configured correctly and is unable to tell what price to place the trade at. Please reconfigure. "; break; //+---- --------------------------------------------------------------+ //| Developer errors | //+------------------------------------------------------------------+ //+---- u - User error Example no CMD //+---- m - Metatrader Example no rates //+---- s - Scanning Example Spread to wide //+---- d - Desk errors Example check can I trade //+---- p - Programer No Need for Exxample case erpTradeLocked: sRetunThis = "A race condition has occurred while waiting to share trading Server at the deal desk "; break; case erpCorrelationLocked: sRetunThis = "A race condition has occurred trying to create a Correlation"; break; case erpSQLLocked: sRetunThis = "A race condition has occurred while waiting to share Run some Sql Commands";break; case erpPivotLocked: sRetunThis = "A race condition has occurred trying to create a Pivot"; break; case erpPatternLocked: sRetunThis = "A race condition has occurred trying to Identify a pattern"; break; case erpSTW: sRetunThis = ""; break; case erpPipe: sRetunThis = "The Expert was unable to initialize a a pipe connection "; break; case ermData: sRetunThis = "Not enough data for the "+mcaGOD[ iParamFunc ].sFileName+" to complete its operations"; break; case erpConnect: sRetunThis = "The Expert was unable to initialize a class instance "; break; case erpLocalInt: sRetunThis = "The Expert was unable to initialize a local instance "; break; case erpPivot: sRetunThis = "The Expert was unable to get pivot information "; break; case erpGidFailed: sRetunThis = "The Expert was unable to load the grid for trading"; break; case erpFailedGMT: sRetunThis = "The Expert was unable to load the GMT offset from the filex"; break; case erpDiabled: sRetunThis = "The Expert has been disabled "; break; case erpFiveTimes: sRetunThis = "The Expert has been disabled after waiting for the error to clear up "; break; case erpUnable2Load: sRetunThis = "The Expert has been unable to process your order and will not try again. The Last Reported error was : "+sError +" in function "+mcaGOD[ iParamFunc ].sFileName; break; case erpNoStopLoss: sRetunThis = "No Stop loss was present for this Ticket "+sBugTicketNumber ; break; //+-------------------------------+ //| Developer errors for Sql | //+-------------------------------+ //+---- u - User error Example no CMD //+---- m - Metatrader Example no rates //+---- s - Scanning Example Spread to wide //+---- d - Desk errors Example check can I trade //+---- p - Programmer No Need for Example case erpNoSqlArray: sRetunThis = "Sql server failed too return the required data"; break; case erpSqlInt: sRetunThis = "Sql server failed to initialize"; break; case erpSqlQuery: sRetunThis = "Sql server failed to retrieve any data from the data base . Nothing was found"; break; case erpSqlInsert: sRetunThis = "Sql server failed to Insert data into the data base"; break; case erpSqlUpdate: sRetunThis = "Sql server failed to update a record in the data base"; break; case erpSqlDelete: sRetunThis = "Sql server failed to delete a record in the data base"; break; //+-------------------------------+ //| Developer errors for Orders | //+-------------------------------+ //+---- u - User error Example no CMD //+---- m - Metatrader Example no rates //+---- s - Scanning Example Spread to wide //+---- d - Desk errors Example check can I trade //+---- p - Programer No Need for Example case erpOrderSendOk: sRetunThis = msEAName + " was unable to send the order in function : " + sFutName; break; case erpOrderModify: sRetunThis = msEAName + " was unable to modify the order in function : " + sFutName+" for ticket Number "+sBugTicketNumber ; break; case erpOrderSelect: sRetunThis = msEAName + " was unable to Select the order in function : " +sFutName+" for ticket Number "+sBugTicketNumber; break; case erpOrderSelectCMD: sRetunThis = msEAName + " was unable to send the order in "+sFutName; break; case erpOrderSelectSYM: sRetunThis = msEAName + " No Cmd Has been set "; break; case erpOrderSelectEA: sRetunThis = "No EA was assigned to trade"; break; case erpOrderSelectDT: sRetunThis = ""; break; case erpOrderDelete: sRetunThis = msEAName + " was unable to Delete the order in function : " + sFutName+" for ticket Number "+sBugTicketNumber; break; case erpOrderClose: sRetunThis = msEAName + " was unable to Close the order in function : " + sFutName+" for ticket Number "+sBugTicketNumber; break; case erpOrderMod : sRetunThis = msEAName + " was unable to modify the order in function : " + sFutName+" for ticket Number "+sBugTicketNumber; break; case erp2Close2Change: sRetunThis = "We are too close and can not change the stop loss"; break; case erpNoMNumber: sRetunThis = msEAName + " was unable to get a magic number the order in function : " + sFutName; break; case erpOverUnder: sRetunThis = msEAName + " was unable to process the Order in function : " + sFutName+" for ticket Number "+sBugTicketNumber+" The spread has changed and it is unable to fill the trade"; break; //+-------------------------------+ //| Desk Errors | //+-------------------------------+ //+---- u - User error Example no CMD //+---- m - Metatrader Example no rates //+---- s - Scanning Example Spread to wide //+---- d - Desk errors Example check can I trade //+---- p - Programer No Need for Example case erdAllowed: sRetunThis = sCompanyName +" is not allowing trading on server "+sAccountServer+" for account number "+sAccountNumber;break ; case erdLotsStep: sRetunThis = sCompanyName +" is not allowing a trade size of "+sRiskToTrade+" on server "+sAccountServer+" for account number "+sAccountNumber;break ; case erdSTMDISABLED: sRetunThis = sCompanyName +" has disabled trading long on server "+sAccountServer+" for account number "+sAccountNumber;break ; case erdSTMSHORTONLY: sRetunThis = sCompanyName +" has disabled trading buying on the symbol "+msEASymbol+" for account number "+sAccountNumber+" On server. " + sAccountServer;break ; case erdSTMLONGONLY: sRetunThis = sCompanyName +" has disabled trading Selling on the symbol "+msEASymbol+" for account number "+sAccountNumber+" On server. " + sAccountServer;break ; case erdSTMCLOSENLY: sRetunThis = sCompanyName +" is only allowing trades to be closed for account number "+sAccountNumber+" On server. "+sAccountServer;break ; case erdMinL: sRetunThis = sCompanyName +" will not allow trades of this size. " + sLots+ " The Trade is too Small. On account number "+sAccountNumber+" On server. "+sAccountServer;break ; ; case erdMaxL: sRetunThis = sCompanyName +" will not allow trades of this size. " + sLots + " The trade is to large. On account number "+sAccountNumber+" On server. "+sAccountServer;break ; ; case erdTarget: sRetunThis = "The target is too close to process"; break; case erdStop: sRetunThis = "The stop is too close to process"; break; case erdWebUTC: sRetunThis = "Unable to Confirm the UTC Offset. Could Not reach the sql server";;break; case erdSymbol: sRetunThis = "Symbol has been turned off for Trading";break; //+-------------------------------+ //| Metatrader Errors | //+-------------------------------+ //+---- u - User error Example no CMD //+---- m - Metatrader Example no rates //+---- s - Scanning Example Spread to wide //+---- d - Desk errors Example check can I trade //+---- p - Programmer No Need for Example case ermVersion: sRetunThis = "This Function was Complied one version "+sTerminal_Build_Complied_Too +" Current Metatrader version is "+sTerminalInfoInteger; case ermRates: sRetunThis = msEASymbol + "Unable to retrieve data for " + msEASymbol + " on " + sTimeFrame; break; case ermMoreData: sRetunThis = "The Function "+sFutName+" Does not have enough data to perform the Analysis"; break; case ermDataZero: sRetunThis = ""; break; case ermDataBad: sRetunThis = ""; break; case ermNoZeroBidAsk: sRetunThis = "There was no bid or ask reported "; break; case ermQTime: sRetunThis = ""; break; case ermSync: sRetunThis = "The Data is out of Sync . The bid Price does not match the Close"; break; case ermFileOpen: sRetunThis = "Unable to open file "+sFilePath; break; case ermAllocateMem: sRetunThis = "Failed to allocate memory for operation in function "+sFutName; //+------------------------------------------------------------------+ //| Scanning is just stopped | //+------------------------------------------------------------------+ //+---- u - User error Example no CMD //+---- m - Metatrader Example no rates //+---- s - Scanning Example Spread to wide //+---- d - Desk errors Example check can I trade //+---- p - Programmer No Need for Example case ersNoBox: sRetunThis = ":: The Expert was unable to load the historical volatility box"; break; case ersTimeHM: sRetunThis = ":: The Ea is not allowed to trade at this time of the day"; break; case ersTimeDay: sRetunThis = ":: The Ea is not allowed to trade at this of Time of day. "+sStartEndTime; break; case ersTBetweenT: sRetunThis = ":: The Ea has been unable to process your order. Currently it will restart in " +sTimeBTrades+ " Minutes "; break; case ersTBetweenE: sRetunThis = ":: The Ea has been unable to process your order. Currently it will restart in " +sTimeBError+ " Minutes " ; break; case ersMaxTrades: sRetunThis = ":: The Ea has reached maximum number of open trades. Currently the open trade count is "+sI2S( mstOpenTrade.iCount)+" the allowed trade count is "+sI2S( mcaUI[ miEANumber ].iMaxTrades );; break; case ersSpread: sRetunThis = ":: Failed Max Spread check"; break; ; case ersMaxLots: sRetunThis = ":: (Trade not allowed): System tried to send a trade with lot size of " + sLots + " that is bigger than tolerance " + sMaxLotsPTrade;break; case ersMaxL : sRetunThis = ":: (Trade not allowed): System tried to send a trade with lot size of " + sLots + " that is bigger than tolerance " + sMaxLotsPTrade; break; case ersMaxDelta: sRetunThis = ":: Total open lot size has been reached " + sMaxLots + " that is bigger than the tolerance of " + DoubleToStr(mcaUI[ miEANumber ].dOpenDeltaEAs,2); break; case ersHVCheck: sRetunThis = ":: The volatility is not in a up swing "; break; case ersNews: sRetunThis = "::"; break; case ersFailedTrend: sRetunThis = "::"; break; case ersNoSpread: sRetunThis = ":: The Bid or ask is missing EA will wait until it clears up"; break; case ersLiarsWiars: sRetunThis = ":: The Ea has has Lost/Won "+sI2S(mstOrderHistory.iLIAR_Counter) +" / "+sI2S(mstOrderHistory.iWIAR_Counter)+" Number of traders this session. The Ea was set to stop after Lost/Won "+ sNumberofLoss+" / "+sNumberOfWin; miOutSide_Stall_After_NumberOfLoss = 0; miOutSide_Stall_After_NumberOfWin = 0; break; case ersHVATR: sRetunThis = ":: Volatility of the day is too low as compared to target and/or stop: "; break; case ersSpreadTPSL: sRetunThis = ":: Tthe Spread is engulfing The Target or the stop : "; break; default: sRetunThis = "Added error code " + sI2S( iUserError); } if(mcaOrders[ miS ].iFailedFiveTimes >0) sReprocess =StringConcatenate( " The System is Trying to reprocesss but have failed " , IntegerToString(mcaOrders[ miS ].iFailedFiveTimes), " times. ") ; iTemporaryError = StringFind(sRetunThis,"::",0); if(iTemporaryError == -1) sRetunThis = StringConcatenate( "An Error Occurred. In the ", mcaGOD[ iParamFunc ].sFutErrOccurredIn, ". " , sRetunThis ,sReprocess); if(iTemporaryError != -1) sRetunThis = "An Temporary event has occurred "+ sRetunThis; //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ //+-------------------------------------------------------------------+ //| Gobal Operation'a Deinitialization | | //+-------------------------------------------------------------------+ //+----- Gobal Operation Deinitialization vGOperationOut(iFunc,__FUNCTION__, __PATH__,sGod); if(ArraySize(sGod)>0) ArrayFree(sGod ); return(sRetunThis); } //+-------------------------------------------------------------------+ //| | //| Function Name: vSetMetatraderStallKillWait.. | //| | //+-------------------------------------------------------------------+ void CBNForexFunctions::vSetMetatraderStallKillWait(int iParamErrorCode , int iParamFuncNumber) { if(menTradingStatus == ENUM_SIGNAL_DISABLE ) return; //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ int iRetryCount = mcaOrders[ miS ].iFailedFiveTimes ; //+-------------------------------------------------------------------+ //| Main Body | //+-------------------------------------------------------------------+ switch(iParamErrorCode) { case 0: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_NO_ERROR 0 No error returned. case 1: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_NO_RESULT 1 No error returned, but the result is unknown. case 4: menTradingStatus = ENUM_SIGNAL_WAIT; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_SERVER_BUSY 4 Trade server is busy. case 9: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_MALFUNCTIONAL_TRADE 9 Malfunctional trade operation. case 128: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TRADE_TIMEOUT 128 Trade timeout. case 129: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_PRICE 129 Invalid price. case 135: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_PRICE_CHANGED 135 Price changed. case 136: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_OFF_QUOTES 136 Off quotes. case 137: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_BROKER_BUSY 137 Broker is busy. case 138: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_REQUOTE 138 Requote. case 139: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_ORDER_LOCKED 139 Order is locked. case 4022: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_SYSTEM_BUSY 4022 System is busy (never generated error) case 4107: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_PRICE_PARAM 4107 Invalid price. case 4058: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_GLOBAL_VARIABLE_NOT_FOUND 4058 Global variable not found. case 5004: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ReProcess //+----- ENUM_SIGNAL_DISABLE case 2: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_COMMON_ERROR 2 Common error. case 3: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_TRADE_PARAMETERS 3 Invalid trade Parameters. case 5: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_OLD_VERSION 5 Old version of the client terminal. case 6: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- No connection with trade server. case 7: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_NOT_ENOUGH_RIGHTS 7 Not enough rights. case 8: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TOO_FREQUENT_REQUESTS 8 Too frequent requests. case 64: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_ACCOUNT_DISABLED 64 Account disabled. case 65: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_ACCOUNT 65 Invalid account. case 130: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_STOPS 130 Invalid stops. case 131: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_TRADE_VOLUME 131 Invalid trade volume. case 132: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_MARKET_CLOSED 132 Market is closed. case 133: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TRADE_DISABLED 133 Trade is disabled. case 134: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_NOT_ENOUGH_MONEY 134 Not enough money. case 140: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_LONG_POSITIONS_ONLY_ALLOWED 140 Long positions only allowed. case 141: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TOO_MANY_REQUESTS 141 Too many requests. case 145: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TRADE_MODIFY_DENIED 145 Modification denied because order too close to market. case 147: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TRADE_EXPIRATION_DENIED 147 Expirations are denied by broker. case 148: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TRADE_TOO_MANY_ORDERS 148 The amount of open and pending orders has reached the limit set by the broker. case 150: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TRADE_HEDGE_PROHIBITED 149 An attempt to open a position opposite to the existing one when hedging is disabled. //------ case 4017: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_DLL_CALLS_NOT_ALLOWED 4017 DLL calls are not allowed. case 4018: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_CANNOT_LOAD_LIBRARY 4018 Cannot load library. case 4019: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_CANNOT_CALL_FUNCTION 4019 Cannot call function. case 4020: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_EXTERNAL_CALLS_NOT_ALLOWED 4020 Expert function calls are not allowed. case 4057: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_GLOBAL_VARIABLES_PROCESSING 4057 Global variables processing error. case 4066: break; //+----- ERR_HISTORY_WILL_UPDATED 4066 Requested history data in updating state. case 4067: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TRADE_ERROR 4067 Some error in trading function. //----- case 4105: break; //+----- ERR_NO_ORDER_SELECTED 4105 No order selected. case 4106: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_UNKNOWN_SYMBOL 4106 Unknown symbol. case 4110: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_TRADE_NOT_ALLOWED 4109 Trade is not allowed. Enable checkbox "Allow live trading" in the expert properties. case 4111: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_SHORTS_NOT_ALLOWED 4111 Shorts are not allowed. Check the expert properties. //+----- ENUM_SIGNAL_STALL && ReProcess case 4000: break; //+----- ERR_NO_MQLERROR 4000 No error. case 4001: break; //+----- ERR_WRONG_FUNCTION_pointER 4001 Wrong function pointer. case 4003: break; //+----- ERR_NO_MEMORY_FOR_CALL_STACK 4003 No memory for function call stack. case 4004: break; //+----- ERR_RECURSIVE_STACK_OVERFLOW 4004 Recursive stack overflow. case 4005: break; //+----- ERR_NOT_ENOUGH_STACK_FOR_PARAM 4005 Not enough stack for Parameter. case 4007: break; //+----- ERR_NO_MEMORY_FOR_TEMP_STRING 4007 No memory for temp string. case 4010: break; //+----- ERR_NO_MEMORY_FOR_ARRAYSTRING 4010 No memory for array string. case 4011: break; //+----- ERR_TOO_LONG_STRING 4011 Too long string. case 4012: break; //+----- ERR_REMAINDER_FROM_ZERO_DIVIDE 4012 Remainder from zero divide. case 4013: break; //+----- ERR_ZERO_DIVIDE 4013 Zero divide. case 4014: break; //+----- ERR_UNKNOWN_COMMAND 4014 Unknown command. case 4015: break; //+----- ERR_WRONG_JUMP 4015 Wrong jump (never generated error). case 4016: break; //+----- ERR_NOT_INITIALIZED_ARRAY 4016 Not initialized array. case 4021: break; //+----- ERR_INVALID_FUNCTION_PARAMSCNT 4050 Invalid function Parameters count. //---------- case 4050: break; //+----- ERR_INVALID_FUNCTION_PARAMVALUE 4051 Invalid function Parameter value. case 4051: break; //+----- ERR_STRING_FUNCTION_INTERNAL 4052 String function internal error. case 4052: break; //+----- ERR_SOME_ARRAY_ERROR 4053 Some array error. case 4054: break; //+----- ERR_INCORRECT_SERIESARRAY_USING 4054 Incorrect series array using. case 4056: break; //+----- ERR_INCOMPATIBLE_ARRAYS 4056 Arrays are incompatible. case 4060: break; //+----- ERR_FUNCTION_NOT_CONFIRMED 4060 Function is not confirmed. case 4061: break; //+----- ERR_SEND_MAIL_ERROR 4061 Send mail error. case 4062: break; //+----- ERR_STRING_PARAMETER_EXPECTED 4062 String Parameter expected. case 4063: break; //+----- ERR_INTEGER_PARAMETER_EXPECTED 4063 Integer Parameter expected. case 4065: break; //+----- ERR_ARRAY_AS_PARAMETER_EXPECTED 4065 Array as Parameter expected. case 4055: break; //+----- ERR_CUSTOM_INDICATOR_ERROR 4055 Custom indicator error. //------------------ case 4099: break; //+----- ERR_END_OF_FILE 4099 End of file. case 4100: break; //+----- ERR_SOME_FILE_ERROR 4100 Some file error. case 4101: break; //+----- ERR_WRONG_FILE_NAME 4101 Wrong file name. case 4102: break; //+----- ERR_TOO_MANY_OPENED_FILES 4102 Too many opened files. case 4103: break; //+----- ERR_CANNOT_OPEN_FILE 4103 Cannot open file. case 4104: break; //+----- ERR_INCOMPATIBLE_FILEACCESS 4104 Incompatible access to a file. case 4108: break; //+----- ERR_INVALID_TICKET 4108 Invalid ticket. ... mostly happens in a close. Depends on the part of the loop it can case 4200: break; //+----- ERR_OBJECT_ALREADY_EXISTS 4200 Object exists already. case 4201: break; //+----- ERR_UNKNOWN_OBJECT_PROPERTY 4201 Unknown object property. case 4202: break; //+----- ERR_OBJECT_DOES_NOT_EXIST 4202 Object does not exist. case 4203: break; //+----- ERR_UNKNOWN_OBJECT_TYPE 4203 Unknown object type. case 4204: break; //+----- ERR_NO_OBJECT_NAME 4204 No object name. case 4205: break; //+----- ERR_OBJECT_COORDINATES_ERROR 4205 Object coordinates error. case 4206: break; //+----- ERR_NO_SPECIFIED_SUBWINDOW 4206 No specified subwindow. case 4207: break; //+----- ERR_SOME_OBJECT_ERROR 4207 Some error in object function } if ( iRetryCount < 5 ) { switch(iParamErrorCode ) { case 0: menTradingStatus = ENUM_SIGNAL_WAIT; mcaGOD[ iParamFuncNumber ].iRetryCount++; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_NO_ERROR 0 No error returned. case 1: menTradingStatus = ENUM_SIGNAL_WAIT; mcaGOD[ iParamFuncNumber ].iRetryCount++; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_NO_RESULT 1 No error returned, but the result is unknown. case 4: menTradingStatus = ENUM_SIGNAL_WAIT; mcaGOD[ iParamFuncNumber ].iRetryCount++; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_SERVER_BUSY 4 Trade server is busy. case 9: menTradingStatus = ENUM_SIGNAL_WAIT; mcaGOD[ iParamFuncNumber ].iRetryCount++; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_MALFUNCTIONAL_TRADE 9 Malfunctional trade operation. case 129: menTradingStatus = ENUM_SIGNAL_WAIT; mcaGOD[ iParamFuncNumber ].iRetryCount++; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_PRICE 129 Invalid price. case 4022: menTradingStatus = ENUM_SIGNAL_WAIT; mcaGOD[ iParamFuncNumber ].iRetryCount++; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_SYSTEM_BUSY 4022 System is busy (never generated error) case 4107: menTradingStatus = ENUM_SIGNAL_WAIT; mcaGOD[ iParamFuncNumber ].iRetryCount++; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_PRICE_PARAM 4107 Invalid price. } } if ( iRetryCount == 5 ) { switch(iParamErrorCode ) { case 0: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_NO_ERROR 0 No error returned. case 1: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_NO_RESULT 1 No error returned, but the result is unknown. case 4: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_SERVER_BUSY 4 Trade server is busy. case 9: menTradingStatus = ENUM_SIGNAL_DISABLE; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_MALFUNCTIONAL_TRADE 9 Malfunctional trade operation. case 129: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_PRICE 129 Invalid price. case 4022: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_SYSTEM_BUSY 4022 System is busy (never generated error) case 4107: menTradingStatus = ENUM_SIGNAL_STALL; mcaOrders[ miS ].iTimeofFailure = (int)dtGetTimeCurrent(); break; //+----- ERR_INVALID_PRICE_PARAM 4107 Invalid price. } } //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ } //+-------------------------------------------------------------------+ //| | //| Function Name: sMetatraderErrorDescription.. | //| | //+-------------------------------------------------------------------+ string CBNForexFunctions::sMetatraderErrorDescription(int iParamErrorCode,int iParamFunc) { //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ string sRetrunThisTemp = ""; string sRetunThis = "" ; string sReprocess = ""; int iRetryCount = mcaOrders[ miS ].iFailedFiveTimes ; //+-------------------------------------------------------------------+ //| Main Body | //+-------------------------------------------------------------------+ switch( iParamErrorCode ) { case 0: sRetunThis = "NO_ERROR" ; break ; case 1: sRetunThis = "NO_RESULT" ; break ; case 2: sRetunThis = "COMMON_ERROR" ; break ; case 3: sRetunThis = "INVALID_TRADE_PARAMETERS" ; break ; case 4: sRetunThis = "SERVER_BUSY" ; break ; case 5: sRetunThis = "OLD_VERSION" ; break ; case 6: sRetunThis = "NO_CONNECTION" ; break ; case 7: sRetunThis = "NOT_ENOUGH_RIGHTS" ; break ; case 8: sRetunThis = "TOO_FREQUENT_REQUESTS" ; break ; case 9: sRetunThis = "MALFUNCTIONAL_TRADE" ; break ; case 64: sRetunThis = "ACCOUNT_DISABLED" ; break ; case 65: sRetunThis = "INVALID_ACCOUNT" ; break ; case 128: sRetunThis = "TRADE_TIMEOUT" ; break ; case 129: sRetunThis = "INVALID_PRICE" ; break ; case 130: sRetunThis = "INVALID_STOPS" ; break ; case 131: sRetunThis = "INVALID_TRADE_VOLUME" ; break ; case 132: sRetunThis = "MARKET_CLOSED" ; break ; case 133: sRetunThis = "TRADE_DISABLED" ; break ; case 134: sRetunThis = "NOT_ENOUGH_MONEY" ; break ; case 135: sRetunThis = "PRICE_CHANGED" ; break ; case 136: sRetunThis = "OFF_QUOTES" ; break ; case 137: sRetunThis = "BROKER_BUSY" ; break ; case 138: sRetunThis = "REQUOTE" ; break ; case 139: sRetunThis = "ORDER_LOCKED" ; break ; case 140: sRetunThis = "LONG_POSITIONS_ONLY_ALLOWED" ; break ; case 141: sRetunThis = "TOO_MANY_REQUESTS" ; break ; case 145: sRetunThis = "TRADE_MODIFY_DENIED" ; break ; case 146: sRetunThis = "TRADE_CONTEXT_BUSY" ; break ; case 147: sRetunThis = "TRADE_EXPIRATION_DENIED" ; break ; case 148: sRetunThis = "TRADE_TOO_MANY_ORDERS" ; break ; case 149: sRetunThis = "TRADE_HEDGE_PROHIBITED" ; break ; case 150: sRetunThis = "TRADE_PROHIBITED_BY_FIFO" ; break ; case 4000: sRetunThis = "NO_MQLERROR" ; break ; case 4001: sRetunThis = "WRONG_FUNCTION_pointER" ; break ; case 4002: sRetunThis = "ARRAY_INDEX_OUT_OF_RANGE" ; break ; case 4003: sRetunThis = "NO_MEMORY_FOR_CALL_STACK" ; break ; case 4004: sRetunThis = "RECURSIVE_STACK_OVERFLOW" ; break ; case 4005: sRetunThis = "NOT_ENOUGH_STACK_FOR_PARAM" ; break ; case 4006: sRetunThis = "NO_MEMORY_FOR_PARAM_STRING" ; break ; case 4007: sRetunThis = "NO_MEMORY_FOR_TEMP_STRING" ; break ; case 4008: sRetunThis = "NOT_INITIALIZED_STRING" ; break ; case 4009: sRetunThis = "NOT_INITIALIZED_ARRAYSTRING" ; break ; case 4010: sRetunThis = "NO_MEMORY_FOR_ARRAYSTRING" ; break ; case 4011: sRetunThis = "TOO_LONG_STRING" ; break ; case 4012: sRetunThis = "REMAINDER_FROM_ZERO_DIVIDE" ; break ; case 4013: sRetunThis = "ZERO_DIVIDE" ; break ; case 4014: sRetunThis = "UNKNOWN_COMMAND" ; break ; case 4015: sRetunThis = "WRONG_JUMP" ; break ; case 4016: sRetunThis = "NOT_INITIALIZED_ARRAY" ; break ; case 4017: sRetunThis = "DLL_CALLS_NOT_ALLOWED" ; break ; case 4018: sRetunThis = "CANNOT_LOAD_LIBRARY" ; break ; case 4019: sRetunThis = "CANNOT_CALL_FUNCTION" ; break ; case 4020: sRetunThis = "EXTERNAL_CALLS_NOT_ALLOWED" ; break ; case 4021: sRetunThis = "NO_MEMORY_FOR_RETURNED_STR" ; break ; case 4022: sRetunThis = "SYSTEM_BUSY" ; break ; case 4050: sRetunThis = "INVALID_FUNCTION_PARAMSCNT" ; break ; case 4051: sRetunThis = "INVALID_FUNCTION_PARAMVALUE" ; break ; case 4052: sRetunThis = "STRING_FUNCTION_INTERNAL" ; break ; case 4053: sRetunThis = "SOME_ARRAY_ERROR" ; break ; case 4054: sRetunThis = "INCORRECT_SERIESARRAY_USING" ; break ; case 4055: sRetunThis = "CUSTOM_INDICATOR_ERROR" ; break ; case 4056: sRetunThis = "INCOMPATIBLE_ARRAYS" ; break ; case 4057: sRetunThis = "GLOBAL_VARIABLES_PROCESSING" ; break ; case 4058: sRetunThis = "GLOBAL_VARIABLE_NOT_FOUND" ; break ; case 4059: sRetunThis = "FUNC_NOT_ALLOWED_IN_TESTING" ; break ; case 4060: sRetunThis = "FUNCTION_NOT_CONFIRMED" ; break ; case 4061: sRetunThis = "SEND_MAIL_ERROR" ; break ; case 4062: sRetunThis = "STRING_PARAMETER_EXPECTED" ; break ; case 4063: sRetunThis = "INTEGER_PARAMETER_EXPECTED" ; break ; case 4064: sRetunThis = "DOUBLE_PARAMETER_EXPECTED" ; break ; case 4065: sRetunThis = "ARRAY_AS_PARAMETER_EXPECTED" ; break ; case 4066: sRetunThis = "HISTORY_WILL_UPDATED" ; break ; case 4067: sRetunThis = "TRADE_ERROR" ; break ; case 4099: sRetunThis = "END_OF_FILE" ; break ; case 4100: sRetunThis = "SOME_FILE_ERROR" ; break ; case 4101: sRetunThis = "WRONG_FILE_NAME" ; break ; case 4102: sRetunThis = "TOO_MANY_OPENED_FILES" ; break ; case 4103: sRetunThis = "CANNOT_OPEN_FILE" ; break ; case 4104: sRetunThis = "INCOMPATIBLE_FILEACCESS" ; break ; case 4105: sRetunThis = "NO_ORDER_SELECTED" ; break ; case 4106: sRetunThis = "UNKNOWN_SYMBOL" ; break ; case 4107: sRetunThis = "INVALID_PRICE_PARAM" ; break ; case 4108: sRetunThis = "INVALID_TICKET" ; break ; case 4109: sRetunThis = "TRADE_NOT_ALLOWED" ; break ; case 4110: sRetunThis = "LONGS_NOT_ALLOWED" ; break ; case 4111: sRetunThis = "SHORTS_NOT_ALLOWED" ; break ; case 4200: sRetunThis = "OBJECT_ALREADY_EXISTS" ; break ; case 4201: sRetunThis = "UNKNOWN_OBJECT_PROPERTY" ; break ; case 4202: sRetunThis = "OBJECT_DOES_NOT_EXIST" ; break ; case 4203: sRetunThis = "UNKNOWN_OBJECT_TYPE" ; break ; case 4204: sRetunThis = "NO_OBJECT_NAME" ; break ; case 4205: sRetunThis = "OBJECT_COORDINATES_ERROR" ; break ; case 4206: sRetunThis = "NO_SPECIFIED_SUBWINDOW" ; break ; case 4207: sRetunThis = "SOME_OBJECT_ERROR" ; break ; case 5004: sRetunThis = "CANNOT_OPEN_FILE "+ mcaGOD[ iParamFunc ].sFileName + " " ; break ; } if(mcaOrders[ miS ].iFailedFiveTimes >0) sReprocess = StringConcatenate( " The System is Trying to reprocesss but have failed " , sI2S(mcaOrders[ miS ].iFailedFiveTimes), " times. ") ; sRetrunThisTemp = StringConcatenate("An Error Occurred while Running the ", msEAName,". On the ",msEASymbol, ". In the " , mcaGOD[ iParamFunc ].sFutErrOccurredIn , ". The Metatrader Error Code reported was : ", sRetunThis , " -- " , sI2S(iParamErrorCode),sReprocess); sRetunThis = sRetrunThisTemp; //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ return(sRetunThis); } //+-------------------------------------------------------------------+ //| | //| iError_TrapTrade. | //| | //|-------------------------------------------------------------------+ int CBNForexFunctions::iError_TrapTrade(int iParamErrorCode) { //+-------------------------------------------------------------------+ //| Gobal Operation'a Initialization | //+-------------------------------------------------------------------+ //+----- Gobal Operation Flow Tracking vGOperationIntArray(__FUNCTION__,__PATH__,__FUNCSIG__); int iFunc = piFunc; string sGod[]; //+----- Stack Control of Errors Initialization vGOperationIn(__FUNCTION__,__PATH__,sGod); //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ int iRetryCount = mcaOrders[ miS ].iFailedFiveTimes ; //+----- ENUM_SIGNAL_STALL && ReProcess if ( iParamErrorCode == 0 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_NO_ERROR 0 No error returned. if ( iParamErrorCode == 1 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_NO_RESULT 1 No error returned, but the result is unknown. if ( iParamErrorCode == 4 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_SERVER_BUSY 4 Trade server is busy. if ( iParamErrorCode == 9 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_MALFUNCTIONAL_TRADE 9 Malfunctional trade operation. if ( iParamErrorCode == 128 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_TRADE_TIMEOUT 128 Trade timeout. if ( iParamErrorCode == 135 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_PRICE_CHANGED 135 Price changed. if ( iParamErrorCode == 136 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_OFF_QUOTES 136 Off quotes. if ( iParamErrorCode == 137 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_BROKER_BUSY 137 Broker is busy. if ( iParamErrorCode == 137 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_REQUOTE 138 Requote. if ( iParamErrorCode == 128 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_TRADE_TIMEOUT 128 Trade timeout. if ( iParamErrorCode == 135 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_PRICE_CHANGED 135 Price changed. if ( iParamErrorCode == 136 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_OFF_QUOTES 136 Off quotes. if ( iParamErrorCode == 137 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_BROKER_BUSY 137 Broker is busy. if ( iParamErrorCode == 138 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_REQUOTE 138 Requote. if ( iParamErrorCode == 139 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_ORDER_LOCKED 139 Order is locked. if ( iParamErrorCode == 139 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_TRADE_CONTEXT_BUSY 146 Trade context is busy. if ( iParamErrorCode == 129 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_INVALID_PRICE 129 Invalid price. if ( iParamErrorCode == 4022 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_SYSTEM_BUSY 4022 System is busy (never generated error) if ( iParamErrorCode == 4107 ) { return(ENUM_SIGNAL_STALL); } //+----- ERR_INVALID_PRICE_PARAM 4107 Invalid price. if ( iRetryCount == 5 ) { if ( iParamErrorCode == 0 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_NO_ERROR 0 No error returned. if ( iParamErrorCode == 1 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_NO_RESULT 1 No error returned, but the result is unknown. if ( iParamErrorCode == 4 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_SERVER_BUSY 4 Trade server is busy. if ( iParamErrorCode == 9 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_MALFUNCTIONAL_TRADE 9 Malfunctional trade operation. if ( iParamErrorCode == 129 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_INVALID_PRICE 129 Invalid price. if ( iParamErrorCode == 4022 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_SYSTEM_BUSY 4022 System is busy (never generated error) if ( iParamErrorCode == 4107 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_INVALID_PRICE_PARAM 4107 Invalid price. } //+----- ReProcess //+----- ENUM_SIGNAL_DISABLE if ( iParamErrorCode == 2 ) { return(ENUM_SIGNAL_DISABLE ); } //+----- ERR_COMMON_ERROR 2 Common error. if ( iParamErrorCode == 3 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_INVALID_TRADE_PARAMETERS 3 Invalid trade Parameters. if ( iParamErrorCode == 5 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_OLD_VERSION 5 Old version of the client terminal. if ( iParamErrorCode == 6 ) { return(ENUM_SIGNAL_DISABLE); } //+----- No connection with trade server. if ( iParamErrorCode == 7 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_NOT_ENOUGH_RIGHTS 7 Not enough rights. if ( iParamErrorCode == 8 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TOO_FREQUENT_REQUESTS 8 Too frequent requests. if ( iParamErrorCode == 64 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_ACCOUNT_DISABLED 64 Account disabled. if ( iParamErrorCode == 65 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_INVALID_ACCOUNT 65 Invalid account. if ( iParamErrorCode == 130 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_INVALID_STOPS 130 Invalid stops. if ( iParamErrorCode == 131 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_INVALID_TRADE_VOLUME 131 Invalid trade volume. if ( iParamErrorCode == 132 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_MARKET_CLOSED 132 Market is closed. if ( iParamErrorCode == 133 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_DISABLED 133 Trade is disabled. if ( iParamErrorCode == 134 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_NOT_ENOUGH_MONEY 134 Not enough money. if ( iParamErrorCode == 140 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_LONG_POSITIONS_ONLY_ALLOWED 140 Long positions only allowed. if ( iParamErrorCode == 141 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TOO_MANY_REQUESTS 141 Too many requests. if ( iParamErrorCode == 145 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_MODIFY_DENIED 145 Modification denied because order too close to market. if ( iParamErrorCode == 147 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_EXPIRATION_DENIED 147 Expirations are denied by broker. if ( iParamErrorCode == 148 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_TOO_MANY_ORDERS 148 The amount of open and pending orders has reached the limit set by the broker. if ( iParamErrorCode == 150 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_HEDGE_PROHIBITED 149 An attempt to open a position opposite to the existing one when hedging is disabled. //------ if ( iParamErrorCode == 4017 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_DLL_CALLS_NOT_ALLOWED 4017 DLL calls are not allowed. if ( iParamErrorCode == 4018 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_CANNOT_LOAD_LIBRARY 4018 Cannot load library. if ( iParamErrorCode == 4019 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_CANNOT_CALL_FUNCTION 4019 Cannot call function. if ( iParamErrorCode == 4020 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_EXTERNAL_CALLS_NOT_ALLOWED 4020 Expert function calls are not allowed. if ( iParamErrorCode == 4058 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_GLOBAL_VARIABLE_NOT_FOUND 4058 Global variable not found. if ( iParamErrorCode == 4057 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_GLOBAL_VARIABLES_PROCESSING 4057 Global variables processing error. if ( iParamErrorCode == 4066 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_HISTORY_WILL_UPDATED 4066 Requested history data in updating state. if ( iParamErrorCode == 4067 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_ERROR 4067 Some error in trading function. //----- if ( iParamErrorCode == 4105 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_NO_ORDER_SELECTED 4105 No order selected. if ( iParamErrorCode == 4106 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_UNKNOWN_SYMBOL 4106 Unknown symbol. if ( iParamErrorCode == 4110 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_NOT_ALLOWED 4109 Trade is not allowed. Enable checkbox "Allow live trading" in the expert properties. if ( iParamErrorCode == 4110 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_NOT_ALLOWED 4109 Trade is not allowed. Enable checkbox "Allow live trading" in the expert properties. if ( iParamErrorCode == 4111 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_SHORTS_NOT_ALLOWED 4111 Shorts are not allowed. Check the expert properties. //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ //+-------------------------------------------------------------------+ //| Gobal Operation'a Deinitialization | | //+-------------------------------------------------------------------+ //+----- Gobal Operation Deinitialization vGOperationOut(iFunc,__FUNCTION__, __PATH__,sGod); if(ArraySize(sGod)>0) ArrayFree(sGod ); return(0); } //+-------------------------------------------------------------------+ //| | //| iError_TrapVars. | //| | //|-------------------------------------------------------------------+ int CBNForexFunctions::iError_TrapVars(int iParamErrorCode) { //+-------------------------------------------------------------------+ //| Gobal Operation'a Initialization | //+-------------------------------------------------------------------+ //+----- Gobal Operation Flow Tracking vGOperationIntArray(__FUNCTION__,__PATH__,__FUNCSIG__); int iFunc = piFunc; string sGod[]; //+----- Stack Control of Errors Initialization vGOperationIn(__FUNCTION__,__PATH__,sGod); //+-------------------------------------------------------------------+ //| Main body | //+-------------------------------------------------------------------+ if ( iParamErrorCode == 4058 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_GLOBAL_VARIABLE_NOT_FOUND 4058 Global variable not found. if ( iParamErrorCode == 4057 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_GLOBAL_VARIABLES_PROCESSING 4057 Global variables processing error. // if ( iParamErrorCode == 4066 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_HISTORY_WILL_UPDATED 4066 Requested history data in updating state. if ( iParamErrorCode == 4067 ) { return(ENUM_SIGNAL_DISABLE); } //+----- ERR_TRADE_ERROR 4067 Some error in trading function. //+----- ---- new if ( iParamErrorCode == 4000 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_MQLERROR 4000 No error. if ( iParamErrorCode == 4001 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_WRONG_FUNCTION_pointER 4001 Wrong function pointer. if ( iParamErrorCode == 4001 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_ARRAY_INDEX_OUT_OF_RANGE 4002 Array index is out of range. if ( iParamErrorCode == 4003 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_MEMORY_FOR_CALL_STACK 4003 No memory for function call stack. if ( iParamErrorCode == 4004 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_RECURSIVE_STACK_OVERFLOW 4004 Recursive stack overflow. if ( iParamErrorCode == 4005 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NOT_ENOUGH_STACK_FOR_PARAM 4005 Not enough stack for Parameter. if ( iParamErrorCode == 4005 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_MEMORY_FOR_PARAM_STRING 4006 No memory for Parameter string. if ( iParamErrorCode == 4007 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_MEMORY_FOR_TEMP_STRING 4007 No memory for temp string. if ( iParamErrorCode == 4018 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NOT_INITIALIZED_STRING 4008 Not initialized string. if ( iParamErrorCode == 4019 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NOT_INITIALIZED_ARRAYSTRING 4009 Not initialized string in array. if ( iParamErrorCode == 4010 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_MEMORY_FOR_ARRAYSTRING 4010 No memory for array string. if ( iParamErrorCode == 4011 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_TOO_LONG_STRING 4011 Too long string. if ( iParamErrorCode == 4012 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_REMAINDER_FROM_ZERO_DIVIDE 4012 Remainder from zero divide. if ( iParamErrorCode == 4013 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_ZERO_DIVIDE 4013 Zero divide. if ( iParamErrorCode == 4014 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_UNKNOWN_COMMAND 4014 Unknown command. if ( iParamErrorCode == 4015 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_WRONG_JUMP 4015 Wrong jump (never generated error). if ( iParamErrorCode == 4016 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NOT_INITIALIZED_ARRAY 4016 Not initialized array. if ( iParamErrorCode == 4017 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_MEMORY_FOR_RETURNED_STR 4021 Not enough memory for temp string returned from function. //---------- if ( iParamErrorCode == 4021 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_INVALID_FUNCTION_PARAMSCNT 4050 Invalid function Parameters count. //---------- if ( iParamErrorCode == 4050 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_INVALID_FUNCTION_PARAMVALUE 4051 Invalid function Parameter value. if ( iParamErrorCode == 4051 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_STRING_FUNCTION_INTERNAL 4052 String function internal error. if ( iParamErrorCode == 4052 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_SOME_ARRAY_ERROR 4053 Some array error. if ( iParamErrorCode == 4054 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_INCORRECT_SERIESARRAY_USING 4054 Incorrect series array using. if ( iParamErrorCode == 4056 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_INCOMPATIBLE_ARRAYS 4056 Arrays are incompatible. if ( iParamErrorCode == 4058 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_GLOBAL_VARIABLE_NOT_FOUND 4058 Global variable not found. if ( iParamErrorCode == 4057 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_GLOBAL_VARIABLES_PROCESSING 4057 Global variables processing error. if ( iParamErrorCode == 4060 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_FUNCTION_NOT_CONFIRMED 4060 Function is not confirmed. if ( iParamErrorCode == 4061 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_SEND_MAIL_ERROR 4061 Send mail error. if ( iParamErrorCode == 4062 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_STRING_PARAMETER_EXPECTED 4062 String Parameter expected. if ( iParamErrorCode == 4063 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_INTEGER_PARAMETER_EXPECTED 4063 Integer Parameter expected. if ( iParamErrorCode == 4062 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_DOUBLE_PARAMETER_EXPECTED 4064 Double Parameter expected. if ( iParamErrorCode == 4065 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_ARRAY_AS_PARAMETER_EXPECTED 4065 Array as Parameter expected. if ( iParamErrorCode == 4055 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_CUSTOM_INDICATOR_ERROR 4055 Custom indicator error. //------------------ if ( iParamErrorCode == 4099 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_END_OF_FILE 4099 End of file. if ( iParamErrorCode == 4100 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_SOME_FILE_ERROR 4100 Some file error. if ( iParamErrorCode == 4101 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_WRONG_FILE_NAME 4101 Wrong file name. if ( iParamErrorCode == 4102 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_TOO_MANY_OPENED_FILES 4102 Too many opened files. if ( iParamErrorCode == 4103 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_CANNOT_OPEN_FILE 4103 Cannot open file. if ( iParamErrorCode == 4104 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_INCOMPATIBLE_FILEACCESS 4104 Incompatible access to a file. //----------- if ( iParamErrorCode == 4108 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_INVALID_TICKET 4108 Invalid ticket. ... mostly happens in a close. Depends on the part of the loop it can if ( iParamErrorCode == 4200 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_OBJECT_ALREADY_EXISTS 4200 Object exists already. if ( iParamErrorCode == 4201 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_UNKNOWN_OBJECT_PROPERTY 4201 Unknown object property. if ( iParamErrorCode == 4202 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_OBJECT_DOES_NOT_EXIST 4202 Object does not exist. if ( iParamErrorCode == 4203 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_UNKNOWN_OBJECT_TYPE 4203 Unknown object type. if ( iParamErrorCode == 4204 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_OBJECT_NAME 4204 No object name. if ( iParamErrorCode == 4205 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_OBJECT_COORDINATES_ERROR 4205 Object coordinates error. if ( iParamErrorCode == 4206 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_SPECIFIED_SUBWINDOW 4206 No specified subwindow. if ( iParamErrorCode == 4207 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_SOME_OBJECT_ERROR 4207 Some error in object function //----------- if ( iParamErrorCode == 4200 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_OBJECT_ALREADY_EXISTS 4200 Object exists already. if ( iParamErrorCode == 4201 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_UNKNOWN_OBJECT_PROPERTY 4201 Unknown object property. if ( iParamErrorCode == 4202 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_OBJECT_DOES_NOT_EXIST 4202 Object does not exist. if ( iParamErrorCode == 4203 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_UNKNOWN_OBJECT_TYPE 4203 Unknown object type. if ( iParamErrorCode == 4204 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_OBJECT_NAME 4204 No object name. if ( iParamErrorCode == 4205 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_OBJECT_COORDINATES_ERROR 4205 Object coordinates error. if ( iParamErrorCode == 4206 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_NO_SPECIFIED_SUBWINDOW 4206 No specified subwindow. if ( iParamErrorCode == 4207 ) { return(ENUM_SIGNAL_TRADE); } //+----- ERR_SOME_OBJECT_ERROR 4207 Some error in object function //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ //+-------------------------------------------------------------------+ //| Gobal Operation'a Deinitialization | | //+-------------------------------------------------------------------+ //+----- Gobal Operation Deinitialization vGOperationOut(iFunc,__FUNCTION__, __PATH__,sGod); if(ArraySize(sGod)>0) ArrayFree(sGod ); return(0); } //+-------------------------------------------------------------------+ //| | //| bIsTemporaryError. | //| | //|-------------------------------------------------------------------+ bool CBNForexFunctions::bIsTemporaryError(int iParamErrorCode) { return( iParamErrorCode == ERR_NO_ERROR || iParamErrorCode == ERR_COMMON_ERROR || iParamErrorCode == ERR_SERVER_BUSY || iParamErrorCode == ERR_NO_CONNECTION || iParamErrorCode == ERR_MARKET_CLOSED || iParamErrorCode == ERR_PRICE_CHANGED || iParamErrorCode == ERR_INVALID_PRICE || //happens sometimes iParamErrorCode == ERR_OFF_QUOTES || iParamErrorCode == ERR_BROKER_BUSY || iParamErrorCode == ERR_REQUOTE || iParamErrorCode == ERR_TRADE_TIMEOUT || iParamErrorCode == ERR_TRADE_CONTEXT_BUSY ); } //+-------------------------------------------------------------------+ //| | //| bMGTWaitOnError. | //| | //|-------------------------------------------------------------------+ //+ ---------------------------------------------------------------- + //+ There are some errors which you can't keep trying to wait + //+ because it will give you the same result. + //+ Return True if it's worth waiting + //+ Return False if it's worth waiting + //+ ---------------------------------------------------------------- + bool CBNForexFunctions::bMGTWaitOnError(int iParamError, ENUM_TRADEOPERATION enParamTradeOperation) { //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ bool bRetunThis = False; //+ ------------------------------------------------ + //+ Known fatal errors: No Waiting is required + //+ ------------------------------------------------ + if ( iParamError == ERR_MARKET_CLOSED || iParamError == ERR_UNKNOWN_SYMBOL || iParamError == ERR_NO_ORDER_SELECTED || iParamError == ERR_ACCOUNT_DISABLED || iParamError == ERR_TRADE_DISABLED || iParamError == ERR_ORDER_LOCKED || iParamError == ERR_INVALID_STOPS || iParamError == ERR_INVALID_TRADE_PARAMETERS || iParamError == ERR_INVALID_ACCOUNT || iParamError == ERR_OLD_VERSION || iParamError == ERR_NOT_ENOUGH_RIGHTS || iParamError == ERR_TRADE_EXPIRATION_DENIED || iParamError == ERR_NO_RESULT || iParamError == ERR_TRADE_MODIFY_DENIED || iParamError == ERR_TRADE_HEDGE_PROHIBITED || iParamError == ERR_NOT_ENOUGH_MONEY || iParamError == ERR_TRADE_PROHIBITED_BY_FIFO || iParamError == ERR_MALFUNCTIONAL_TRADE || iParamError == ERR_TRADE_ERROR || iParamError == ERR_TRADE_NOT_ALLOWED || iParamError == ERR_LONG_POSITIONS_ONLY_ALLOWED || iParamError == ERR_COMMON_ERROR ) { bRetunThis = False; } //+ ------------------------------------------------ + //+ Temporary error: Continue Waiting + //+ ------------------------------------------------ + else if ( iParamError == ERR_SERVER_BUSY || iParamError == ERR_BROKER_BUSY || iParamError == ERR_NO_ERROR || iParamError == ERR_NO_CONNECTION || iParamError == ERR_TRADE_CONTEXT_BUSY || iParamError == ERR_TRADE_TIMEOUT || iParamError == ERR_OFF_QUOTES || iParamError == ERR_REQUOTE || iParamError == ERR_PRICE_CHANGED || iParamError == ERR_INVALID_PRICE || iParamError == ERR_INVALID_TRADE_VOLUME ) { Sleep(10); bRetunThis = True; } else if ( iParamError == ERR_TRADE_TOO_MANY_ORDERS || iParamError == ERR_TOO_MANY_REQUESTS ) { Sleep(1600); bRetunThis = True; } else bRetunThis = False; //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ return(bRetunThis); } //+-------------------------------------------------------------------+ //| | //| iSetProgramType.. | //| | //|-------------------------------------------------------------------+ //+----- --------------------------------------------------------------------------- | //+----- Make Index Key for Debugging | //+----- --------------------------------------------------------------------------- | int CBNForexFunctions::iSetProgramType( ) { //+-------------------------------------------------------------------+ //| Initialization of Function | //+-------------------------------------------------------------------+ //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ int iRetunThis = 0; ENUM_PROGRAM_TYPE mql_program = (ENUM_PROGRAM_TYPE)MQLInfoInteger(MQL_PROGRAM_TYPE); switch(mql_program) { case PROGRAM_SCRIPT: { iRetunThis = deScriptYN; break; } case PROGRAM_EXPERT: { iRetunThis = deExpertYN; break; } case PROGRAM_INDICATOR: { iRetunThis = deIndYn; break; } default: iRetunThis = 0; } //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ return(iRetunThis); } //+-------------------------------------------------------------------+ //| | //| sErrorDefines2String. | //| | //|-------------------------------------------------------------------+ string CBNForexFunctions::sErrorDefines2String(int iParamDefines, int iParamUseTwo = 1) { string sTempOne = ""; string sTempTwo = ""; string sReturnThis = ""; if(iParamDefines == -1) { sTempOne = "erLevelOne"; sTempTwo = "A Error Level one was tripped";}; if(iParamDefines == -2) { sTempOne = "erLevelTwo"; sTempTwo = "A Error Level two was tripped";}; if(iParamDefines == -3) { sTempOne = "erLevelThree"; sTempTwo = "A Error Level Three was tripped";}; //+------------------------------------------------------------------+ //| User Input errors | //+------------------------------------------------------------------+ //+---- u - User error //+---- p - Programer //+---- d - Desk errors //+---- m - metatrader //+---- s - scanning not critical no fail if(iParamDefines == -1 ) { sTempOne = "eruNoCMD"; sTempTwo = "bUserOrderZeroVal";}; if(iParamDefines == -2 ) { sTempOne = "eruNoLots"; sTempTwo = "bUserOrderZeroVal";}; if(iParamDefines == -3 ) { sTempOne = "eruNoEPrice"; sTempTwo = "bUserOrderZeroVal";}; if(iParamDefines == -4 ) { sTempOne = "eruNoSPrice"; sTempTwo = "bUserOrderZeroVal";}; if(iParamDefines == -5 ) { sTempOne = "eruNoTPrice"; sTempTwo = "bUserOrderZeroVal";}; if(iParamDefines == -6 ) { sTempOne = "eruNoExp"; sTempTwo = "bUserOrderZeroVal";}; if(iParamDefines == -7 ) { sTempOne = "eruNoSymbol"; sTempTwo = "bMT4OrderZeroVal";}; if(iParamDefines == -8 ) { sTempOne = "eruMaxLossOpen"; sTempTwo = "bUseMaximumDrawDownOpen";}; if(iParamDefines == -9 ) { sTempOne = "eruEAInstance"; sTempTwo = "bUserAlreadyRunningEA";}; if(iParamDefines == -10 ) { sTempOne = "eruDllChecked"; sTempTwo = "bUserValidateDllsAllowed";}; if(iParamDefines == -11 ) { sTempOne = "eruEmail"; sTempTwo = "bUserUserValidateEmail";}; if(iParamDefines == -12 ) { sTempOne = "eruMaxLossClosed"; sTempTwo = "bUserValidate_MaximumDrawDown";}; if(iParamDefines == -13 ) { sTempOne = "eruTradingAllowed"; sTempTwo = "bUserValidateTradeAllowed";}; if(iParamDefines == -14 ) { sTempOne = "eruDllChecked"; sTempTwo = "bUserValidateDllsAllowed";}; if(iParamDefines == -15 ) { sTempOne = "eruFifoFailedClo"; sTempTwo = "bDeskFifoError";}; if(iParamDefines == -16 ) { sTempOne = "erpUnable2Load"; sTempTwo = "bUserInputFile";}; if(iParamDefines == -17 ) { sTempOne = "eruEaAuth"; sTempTwo = "vInitialize";}; if(iParamDefines == -18 ) { sTempOne = "eruEaWrongTF"; sTempTwo = "vBoxBuilderBBBand";}; if(iParamDefines == -19 ) { sTempOne = "eruNoTrend"; sTempTwo = "bUserValidate_TrendCheck";}; if(iParamDefines == -20 ) { sTempOne = "eruAlreadyRunning"; sTempTwo = "bUserCheckTradingEA";}; //+------------------------------------------------------------------+ //| Developer errors | //+------------------------------------------------------------------+ //+---- u - User error //+---- p - Programer //+---- d - Desk errors //+---- m - metatrader //+---- s - scanning not critical no fail if(iParamDefines == -100 ) { sTempOne = "erpTradeLocked"; sTempTwo = "vDevCheckLOCKed";}; if(iParamDefines == -101 ) { sTempOne = "erpPatternLocked"; sTempTwo = "bDevCheckLOCKed";}; if(iParamDefines == -102 ) { sTempOne = "erpSTW"; sTempTwo = "";}; if(iParamDefines == -103 ) { sTempOne = "erpOverUnder"; sTempTwo = "bMT4OverUnder";}; if(iParamDefines == -104 ) { sTempOne = "erpPipe"; sTempTwo = "";}; if(iParamDefines == -106 ) { sTempOne = "erpInt"; sTempTwo = "bMT4Connected";}; if(iParamDefines == -107 ) { sTempOne = "erpLocalInt"; sTempTwo = "bDevValidateLocalInt";}; if(iParamDefines == -108 ) { sTempOne = "erpPivot"; sTempTwo = "";}; if(iParamDefines == -109 ) { sTempOne = "erpGidFailed"; sTempTwo = "iGridPrep";}; if(iParamDefines == -111 ) { sTempOne = "erpFailedGMT"; sTempTwo = "bDevConnected";}; if(iParamDefines == -112 ) { sTempOne = "erpDiabled"; sTempTwo = "bDevValidate_DisabledEA";}; if(iParamDefines == -113 ) { sTempOne = "erpFiveTimes"; sTempTwo = "bDevValidate_FailedFiveTimes";}; if(iParamDefines == -114 ) { sTempOne = "erpNoStopLoss"; sTempTwo = "vFailSafeNoSL";}; if(iParamDefines == -115 ) { sTempOne = "erpDisableEA"; sTempTwo = "bExecuteExternalControl";}; if(iParamDefines == -116 ) { sTempOne = "erpStallEA"; sTempTwo = "bInitializeEALocal";}; if(iParamDefines == -117 ) { sTempOne = "erpSQLLocked"; sTempTwo = "vDevCheckLOCKed";}; if(iParamDefines == -118 ) { sTempOne = "erpCorrelationLocked"; sTempTwo = "vDevCheckLOCKed";}; if(iParamDefines == -119 ) { sTempOne = "erpPivotLocked"; sTempTwo = "vDevCheckLOCKed";}; //+-------------------------------+ //| Developer errors for Sql | //+-------------------------------+ //+---- u - User error //+---- p - Programer //+---- d - Desk errors //+---- m - metatrader //+---- s - scanning not critical no fail if(iParamDefines == -150 ) { sTempOne = "erpNoSqlArray"; sTempTwo = "bSelect";}; if(iParamDefines == -151 ) { sTempOne = "erpSqlInt"; sTempTwo = "bINTSQL";}; if(iParamDefines == -152 ) { sTempOne = "erpSqlInsert"; sTempTwo = "bInsert";}; if(iParamDefines == -153 ) { sTempOne = "erpSqlQuery"; sTempTwo = "bSelect";}; if(iParamDefines == -154 ) { sTempOne = "erpSqlUpdate"; sTempTwo = "bUpdate";}; if(iParamDefines == -15 ) { sTempOne = "erpSqlDelete"; sTempTwo = "";}; //+-------------------------------+ //| Developer errors for Orders | //+-------------------------------+ //+---- u - User error //+---- p - Programer //+---- d - Desk errors //+---- m - metatrader //+---- s - scanning not critical no fail if(iParamDefines == -175 ) { sTempOne = "erpOrderSendOk"; sTempTwo = "iOrderHubOpen";}; if(iParamDefines == -176 ) { sTempOne = "erpOrderModify"; sTempTwo = "bOrderModHub";}; if(iParamDefines == -177 ) { sTempOne = "erpOrderSelect"; sTempTwo = "iGridPrep";}; if(iParamDefines == -178 ) { sTempOne = "erpOrderSelectCM"; sTempTwo = "";}; if(iParamDefines == -179 ) { sTempOne = "erpOrderSelectSY"; sTempTwo = "";}; if(iParamDefines == -180 ) { sTempOne = "erpOrderSelectEA"; sTempTwo = "";}; if(iParamDefines == -181 ) { sTempOne = "erpOrderSelectDT"; sTempTwo = "";}; if(iParamDefines == -182 ) { sTempOne = "erpOrderDelete"; sTempTwo = "bOrderCloseDeleteHub";}; if(iParamDefines == -183 ) { sTempOne = "erpOrderClose"; sTempTwo = "bOrderClose";}; if(iParamDefines == -184 ) { sTempOne = "erpOrderMod"; sTempTwo = "bOrderModHub";}; if(iParamDefines == -185 ) { sTempOne = "erp2Close2Change"; sTempTwo = "";}; if(iParamDefines == -186 ) { sTempOne = "erpNoMNumber"; sTempTwo = "bUserOrderZeroVal";}; //+-------------------------------+ //| Desk Errors | //+-------------------------------+ //+---- u - User error //+---- p - Programer //+---- d - Desk errors //+---- m - metatrader //+---- s - scanning not critical no fail if(iParamDefines == -200 ) { sTempOne = "erdAllowed"; sTempTwo = "bDeskTradeAllowedBusy";}; if(iParamDefines == -201 ) { sTempOne = "erdLotsStep"; sTempTwo = "";}; if(iParamDefines == -202 ) { sTempOne = "erdSTMDISABLED"; sTempTwo = "";}; if(iParamDefines == -203 ) { sTempOne = "erdSTMSHORTONLY"; sTempTwo = "";}; if(iParamDefines == -204 ) { sTempOne = "erdSTMLONGONLY"; sTempTwo = "";}; if(iParamDefines == -205 ) { sTempOne = "erdSTMCLOSENLY"; sTempTwo = "";}; if(iParamDefines == -205 ) { sTempOne = "erdFifoFailedClose"; sTempTwo = "";}; if(iParamDefines == -207 ) { sTempOne = "erdMinL"; sTempTwo = "bDeskMinLots";}; if(iParamDefines == -208 ) { sTempOne = "erdMaxL"; sTempTwo = "bDeskMaxLots";}; if(iParamDefines == -209 ) { sTempOne = "erdTarget"; sTempTwo = "";}; if(iParamDefines == -210 ) { sTempOne = "erdStop"; sTempTwo = "bDevValidate_StopTooTight";}; if(iParamDefines == -211 ) { sTempOne = "erdWebUTC"; sTempTwo = "vDevSetErrorWeb";}; if(iParamDefines == -212 ) { sTempOne = "erdMargin"; sTempTwo = "bDesksPassFreeMarginCheck";}; if(iParamDefines == -213 ) { sTempOne = "erdSymbol"; sTempTwo = "bDeskValidate_SymbolOn";}; if(iParamDefines == -214 ) { sTempOne = "erdMaxLotsDesk"; sTempTwo = "";}; //+-------------------------------+ //| Metatrader Errors | //+-------------------------------+ //+---- u - User error //+---- p - Programer //+---- d - Desk errors //+---- m - metatrader //+---- s - scanning not critical no fail if(iParamDefines == -226 ) { sTempOne = "ermVersion"; sTempTwo = "bMT4Validate_VersionNumber";}; if(iParamDefines == -227 ) { sTempOne = "ermSync"; sTempTwo = "bMt4CheckOutOfSync";}; if(iParamDefines == -228 ) { sTempOne = "ermRates"; sTempTwo = "iDownloadHistory";}; if(iParamDefines == -229 ) { sTempOne = "ermMoreData"; sTempTwo = "GetPivot";}; if(iParamDefines == -230 ) { sTempOne = "ermDataZero"; sTempTwo = "";}; if(iParamDefines == -231 ) { sTempOne = "ermDataBad"; sTempTwo = "";}; if(iParamDefines == -232 ) { sTempOne = "ermNoZeroBidAsk"; sTempTwo = "";}; if(iParamDefines == -215 ) { sTempOne = "ermQTime"; sTempTwo = "bDevCheckQuoteTime";}; if(iParamDefines == -234 ) { sTempOne = "ermStop"; sTempTwo = "bMT4StopCheckMT";}; if(iParamDefines == -234 ) { sTempOne = "ermTarget"; sTempTwo = "bMT4TargetCheckMT";}; if(iParamDefines == -235 ) { sTempOne = "ermMaxL"; sTempTwo = "";}; if(iParamDefines == -236 ) { sTempOne = "ermFileOpen"; sTempTwo = "iFileOpen";}; if(iParamDefines == -237 ) { sTempOne = "ermAllocateMem"; sTempTwo = "GetPivot";}; //+------------------------------------------------------------------+ //| Scanning is just stopped | //+------------------------------------------------------------------+ //+---- u - User error //+---- p - Programer //+---- d - Desk errors //+---- m - metatrader //+---- s - scanning not critical no fail if(iParamDefines == -300 ) { sTempOne = "ersTimeHM"; sTempTwo = "";}; if(iParamDefines == -301 ) { sTempOne = "ersTimeDay"; sTempTwo = "bScanValidate_TimeToTrade";}; if(iParamDefines == -302 ) { sTempOne = "ersTBetweenT"; sTempTwo = "bScanValidate_TimeBetweenTrade";}; if(iParamDefines == -303 ) { sTempOne = "ersTBetweenE"; sTempTwo = "bScanValidate_TimeBetweenError";}; if(iParamDefines == -304 ) { sTempOne = "ersMaxTrades"; sTempTwo = "bScanValidate_MaximumOpenTrade";}; if(iParamDefines == -305 ) { sTempOne = "ersSpread"; sTempTwo = "bScanValidate_TooWideSpreadSLTP";}; if(iParamDefines == -306 ) { sTempOne = "ersMaxLots"; sTempTwo = "bScanValidate_MaximumLotPerTrade";}; if(iParamDefines == -308 ) { sTempOne = "ersMinL"; sTempTwo = "";}; if(iParamDefines == -309 ) { sTempOne = "ersMaxDelta"; sTempTwo = "bScanValidate_TotalLotSize";}; if(iParamDefines == -310 ) { sTempOne = "ersHVCheck"; sTempTwo = "bScanScanValidate_TimeOfDayHV";}; if(iParamDefines == -311 ) { sTempOne = "ersNews"; sTempTwo = "";}; if(iParamDefines == -312 ) { sTempOne = "ersFailedTrend"; sTempTwo = "";}; if(iParamDefines == -313 ) { sTempOne = "ersLiarsWiars"; sTempTwo = "";}; if(iParamDefines == -314 ) { sTempOne = "ersHVATR"; sTempTwo = "bScanValidate_Volatility";}; if(iParamDefines == -315 ) { sTempOne = "ersNoBox"; sTempTwo = "bScanValidate_HVBox";}; if(iParamDefines == -316 ) { sTempOne = "ersSpreadTPSL"; sTempTwo = "bScanValidate_TooWideSpreadSLTP";}; if(iParamDefines == -317 ) { sTempOne = "ersNoSpread"; sTempTwo = "";}; return(sReturnThis); } //+-------------------------------------------------------------------+ //| | //| bError4066. | //| | //|-------------------------------------------------------------------+ bool CBNForexFunctions::bError4066() { //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ RefreshRates(); bool bReturnThis = false; datetime dtRetunThis = 0; datetime dtCurrentTime = TimeCurrent(); datetime dtCurrentM1Time = iTime(msEASymbol, PERIOD_M1, 0); datetime dtCurrentTimeFrame = iTime(msEASymbol, miEATimeFrame, 0); int iError = 0; //+-------------------------------------------------------------------+ //| Main body | //+-------------------------------------------------------------------+ while(!bReturnThis) { if ( dtCurrentTime >= dtCurrentM1Time && dtCurrentTime >= dtCurrentTimeFrame ) dtRetunThis = dtCurrentTime; else if ( dtCurrentM1Time >= dtCurrentTimeFrame && dtCurrentM1Time >= dtCurrentTime ) dtRetunThis = dtCurrentM1Time; else if ( dtCurrentTimeFrame >= dtCurrentM1Time && dtCurrentTimeFrame >= dtCurrentTime ) dtRetunThis = dtCurrentTimeFrame; else dtRetunThis = dtCurrentTime; iError = GetLastError(); if( iError == 4066 ) {ResetLastError(); Sleep(1000); RefreshRates(); } else break; } bReturnThis = true; //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ mcaGOD[ piFunc ].sDebuggerURL1 = " https://www.mql5.com/en/forum/143422"; return(bReturnThis); } //+-------------------------------------------------------------------+ //| | //| bError4073.. | //| | //|-------------------------------------------------------------------+ bool CBNForexFunctions::bError4073() { //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ RefreshRates(); bool bReturnThis = false; datetime dtRetunThis = 0; datetime dtCurrentTime = TimeCurrent(); datetime dtCurrentM1Time = iTime(msEASymbol, PERIOD_M1, 0); datetime dtCurrentTimeFrame = iTime(msEASymbol, miEATimeFrame, 0); int iError = 0; //+-------------------------------------------------------------------+ //| Main body | //+-------------------------------------------------------------------+ while(!bReturnThis) { if ( dtCurrentTime >= dtCurrentM1Time && dtCurrentTime >= dtCurrentTimeFrame ) dtRetunThis = dtCurrentTime; else if ( dtCurrentM1Time >= dtCurrentTimeFrame && dtCurrentM1Time >= dtCurrentTime ) dtRetunThis = dtCurrentM1Time; else if ( dtCurrentTimeFrame >= dtCurrentM1Time && dtCurrentTimeFrame >= dtCurrentTime ) dtRetunThis = dtCurrentTimeFrame; else dtRetunThis = dtCurrentTime; iError = GetLastError(); if( iError == 4073 ) {ResetLastError(); Sleep(1000); RefreshRates(); } else break; } bReturnThis = true; //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ //+----- https://www.mql5.com/en/forum/143422 return(bReturnThis); } //+-------------------------------------------------------------------+ //| | //| vErrorLog.. | //| | //|-------------------------------------------------------------------+ void CBNForexFunctions::vErrorLog() { //+-------------------------------------------------------------------+ //| Local Variables Initialization | //+-------------------------------------------------------------------+ int iTypeFunctions = (int)dGetGVar(deBug,msEAName, msEASymbol, miEATypeOfTrade, miEATimeFrame, deTypeFunctions,0); int iFunctionOnly = (int)dGetGVar(deBug,msEAName, msEASymbol, miEATypeOfTrade, miEATimeFrame, deFunctionOnly,0); int iAllFunctions = (int)dGetGVar(deBug,msEAName, msEASymbol, miEATypeOfTrade, miEATimeFrame, deTypeFunctions,0); //+-------------------------------------------------------------------+ //| Main body | //+-------------------------------------------------------------------+ if( iTypeFunctions != 0 && mcaGOD[ 0 ].sFutType == mcaGOD[ piFunc ].sFutType ) miShowError = piFunc; if( iFunctionOnly != 0 && mcaGOD[ iFunctionOnly ].iFunNum == mcaGOD[ piFunc ].iFunNum ) miShowError = piFunc; if( iAllFunctions != 0 ) miShowError = piFunc; //+-------------------------------------------------------------------+ //| Deinitialization of Function | //+-------------------------------------------------------------------+ //+----- https://www.mql5.com/en/forum/143422 }