Cloud Strategy Tester: error 0 in line 1 and column 1?

 

Hi!

I enabled now the CLOUD STRATEGY TESTER and putting my EA to run there some tests I have the following error on all passes:

2023.07.18 21:53:22.209 MQL5 Cloud USA 2 pass 292 tested with error "critical runtime error 0 in OnInit function (error code 0, module Experts\2023\EA v3.962.ex5, file 65535, line 1, col 1)" in 0:00:00.549 (PR 138)


I cannot understand what is going on since I run "Complete Algorithm" tests locally without any problem, and either the reported error as well the line/column seems mean "no error".

In time: basically my EA uses custom indicators (available here, both .MQ5 and .EX5) and the "line 1 column 1" have no special characters.


Follows the header of my EA and the start-lines of the OnInit function...


//+------------------------------------------------------------------+
//|                                                 My Robot v 3.962 |
//|                                                      A. Nogueira |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+

#define   VERSION       "3.962"
#property copyright     "Alice Nogueira"
#property link          "https://www.mywebsite.com.br"
#property description   "Algoritmo customizável."
#property version   VERSION

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>

CTrade         m_trade;                      // trading object
CSymbolInfo    m_symbol;                     // symbol info object
CAccountInfo   m_account;                    // account info wrapper
CPositionInfo  m_position;                   // trade position object


( ... and so forth)


 ... and the OnInit function has:


int OnInit()
{

            SymbolSelect("XAUUSD", true);

            string period_xxx  = EnumToString(_Period);
            string Periodo_String = StringSubstr(period_xxx, 7);


///////////////////////////////////////////////////////////////////////////////////////////////////////

            string broker = AccountInfoString(ACCOUNT_COMPANY);
            long account = AccountInfoInteger(ACCOUNT_LOGIN);



( ... and so forth)


I appreciate any help.

 
AliceRioBR:

Hi!

I enabled now the CLOUD STRATEGY TESTER and putting my EA to run there some tests I have the following error on all passes:

2023.07.18 21:53:22.209 MQL5 Cloud USA 2 pass 292 tested with error "critical runtime error 0 in OnInit function (error code 0, module Experts\2023\EA v3.962.ex5, file 65535, line 1, col 1)" in 0:00:00.549 (PR 138)


I cannot understand what is going on since I run "Complete Algorithm" tests locally without any problem, and either the reported error as well the line/column seems mean "no error".

In time: basically my EA uses custom indicators (available here, both .MQ5 and .EX5) and the "line 1 column 1" have no special characters.


Follows the header of my EA and the start-lines of the OnInit function...



 ... and the OnInit function has:



I appreciate any help.

If the error message says error in OnInit() you could at least post the full OnInit() code !

 
Alain Verleyen #:

If the error message says error in OnInit() you could at least post the full OnInit() code !

Hi Alain!

Follows my complete OnInit, without some "comments" lines.

Please, note that some SQLITE DATABASE operations are DISABLED by default parameters in my EA.

Thank for any light on this.

int OnInit()
{

            SymbolSelect("XAUUSD", true);

            string period_xxx  = EnumToString(_Period);
            string Periodo_String = StringSubstr(period_xxx, 7);

///////////////////////////////////////////////////////////////////////////////////////////////////////

            string broker = AccountInfoString(ACCOUNT_COMPANY);
            long account = AccountInfoInteger(ACCOUNT_LOGIN);

///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////


    // LogaDeals is NOT "SIM" and it will be used to log operations in a local (or VPN) database

    if(LogaDeals == SIM)
      {
            
            string DiaHora2File = TimeToString(TimeLocal(), TIME_DATE|TIME_MINUTES);
            int Resultado = StringReplace(DiaHora2File,":",".");
            

            db_filename = "XAUUSD_" + versao + "_" + DiaHora2File + "_" + IntegerToString(account, 0) + ".sqlite";
            StringReplace(db_filename, "S/A", "");
            Print("====================================");
            Print("Database em: ", common_folder, "\\files\\", db_filename);
            Print("====================================");


            //--- open/create the database in the common terminal folder

            BDados = DatabaseOpen(db_filename, DATABASE_OPEN_READWRITE | DATABASE_OPEN_CREATE | DATABASE_OPEN_COMMON);
            if(BDados == INVALID_HANDLE)
            {           Print("DB: ", db_filename, " open failed with code ", GetLastError());
                        return(INIT_FAILED);
            }

            if(!CreateTableDeals(BDados))
            {           DatabaseClose(BDados);
                        return(INIT_FAILED);
            }

            if(!CreateTableIndicators(BDados))
            {           DatabaseClose(BDados);
                        return(INIT_FAILED);
            }


       
      }



// ----- Temporarily disabled.

            /*

                    for (int i = 0; i < ArraySize(allowed_brokers); i++)
                            if (broker == allowed_brokers[i])
                            {

                                    for (int j = 0; j < ArraySize(allowed_accounts); j++)
                                            if (account == allowed_accounts[j])
                                            {
                                                    password_status = 1;
                                                    Print("EA account verified");
                                                    break;
                                            }
                            }





                    if (password_status != 1)
                    {
                            Send_Status("EA não habilitado para essa conta: " + broker + ", " + IntegerToString(account,0)  , "EA not enabled to this account: "  + broker + ", " + IntegerToString(account));
                            Write_to_Log("EA não habilitado para essa máquina: "  + broker + ", " + IntegerToString(account,0));

                            ExpertRemove();
                            return(INIT_FAILED);
                    }


            */



// -------------------------------


            if(Must_SL == DINAMICOS_DISTANCIA_PONTOS || Must_SL == FIXOS)
            {           m_SL_Normal       = Inp_SL_Inicial                * _Point;
                        m_TP_Normal       = Inp_TP_Inicial                * _Point;

            }
            else
            {           m_SL_Normal       = 0;
                        m_TP_Normal       = 0;
                        m_PointsForLucro  = 0;
            }

            Deslocamento            = DeslocamentoTPSL * _Point;



///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////    CUSTOM  INDICATORS    //////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

        // NAO is an enum and corresponds to NO
        // SIM is an enum and corresponds to YES


            if(Show_MA1 == NAO)
            { TesterHideIndicators(true); }
            else
              { TesterHideIndicators(false);  }


            Print("inicializando MA.");
            hMA1 = iCustom(_Symbol, _Period, "custom_MA", MA1_Period, MA1_Shift, MA1_Method, MA1_Color, MA1_Estilo, MA1_Largura);
            if(hMA1 == INVALID_HANDLE)
            {           DisplayErroIndicator("MA");
                        return(100);
            }
            else ChartIndicatorAdd(0, 0, hMA1);
           
            ArraySetAsSeries(MA1, true);






            if(Show_MA2 == NAO)
            { TesterHideIndicators(true); }
            else
              { TesterHideIndicators(false);  }


            Print("inicializando MA.");
            hMA2 = iCustom(_Symbol, _Period, "custom_MA", MA2_Period, MA2_Shift, MA2_Method, MA2_Color, MA2_Estilo, MA2_Largura);
            if(hMA2 == INVALID_HANDLE)
            {           DisplayErroIndicator("MA");
                        return(101);
            }
            else ChartIndicatorAdd(0, 0, hMA2);
           
            ArraySetAsSeries(MA2, true);




            if(Show_MA3 == NAO)
            { TesterHideIndicators(true); }
            else
              { TesterHideIndicators(false);  }


            Print("inicializando MA.");
            hMA3 = iCustom(_Symbol, _Period, "custom_MA", MA3_Period, MA3_Shift, MA3_Method, MA3_Color, MA3_Estilo, MA3_Largura);
            if(hMA3 == INVALID_HANDLE)
            {           DisplayErroIndicator("MA");
                        return(102);
            }
            else ChartIndicatorAdd(0, 0, hMA3);
           
            ArraySetAsSeries(MA3, true);



            if(Show_MA4 == NAO)
            { TesterHideIndicators(true); }
            else
              { TesterHideIndicators(false);  }


            Print("inicializando MA.");
            hMA4 = iCustom(_Symbol, _Period, "custom_MA", MA4_Period, MA4_Shift, MA4_Method, MA4_Color, MA4_Estilo, MA4_Largura);
            if(hMA4 == INVALID_HANDLE)
            {           DisplayErroIndicator("MA");
                        return(103);
            }
            else ChartIndicatorAdd(0, 0, hMA4);
           
            ArraySetAsSeries(MA4, true);




            if(Show_PoliRegr == NAO)
            { TesterHideIndicators(true); }
            else
              { TesterHideIndicators(false);  }


            Print("inicializando Regresssão Polinomial");
            hPoli = iCustom(_Symbol, _Period, "PoliRegr_v3", PoliRegr_degree, PoliRegr_kstd, PoliRegr_bars, PoliRegr_nextBars);
            if(hPoli == INVALID_HANDLE)
            {           DisplayErroIndicator("Polinomial Regression");
                        return(105);
            }
            else ChartIndicatorAdd(0, 0, hPoli);
           
             ArraySetAsSeries(Poli_hBuffer, true);
             ArraySetAsSeries(Poli_mBuffer, true);
             ArraySetAsSeries(Poli_lBuffer, true);
            


            if(Show_CCI == NAO)
            { TesterHideIndicators(true); }
            else
              { TesterHideIndicators(false);  }


            Print("inicializando CCI");
            hCCI = iCustom(_Symbol, _Period, "custom_CCI", CCI_Period, CCI_Color, CCI_Estilo, CCI_Largura, CCI_Level_MIN, CCI_Level_MAX, CCI_Level_Trigger_MIN, CCI_Level_Trigger_MAX, CCI_Levels_Color, CCI_Level_Triggers_Color);
            if(hCCI == INVALID_HANDLE)
            {           DisplayErroIndicator("Commodity Index");
                        return(105);
            }
            else 
            {
                subwindow = ChartGetInteger(0, CHART_WINDOWS_TOTAL);
                if(!ChartIndicatorAdd(0, subwindow, hCCI))
                {
                        PrintFormat("Falha em adicionar CCI (Commodity Index) na janela chart %d. Error code  %d", subwindow,GetLastError());
                        return(INIT_FAILED);
                }
            }
           
            ArraySetAsSeries(CCI_Value, true);
            



// -----------------------------------------



            Leverage_da_Conta = (int)AccountInfoInteger(ACCOUNT_LEVERAGE);

            Print("Broker : " + broker);

            Print("Conta  : " + AccountInfoString(ACCOUNT_NAME));
            Print("Conta #: " + IntegerToString(account, 0));

            Print("Conpany: " + AccountInfoString(ACCOUNT_COMPANY));
            Print("Server : " + AccountInfoString(ACCOUNT_SERVER));




//--- Account number

            ENUM_ACCOUNT_TRADE_MODE mode = (ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE);

            switch(mode)
            {           case ACCOUNT_TRADE_MODE_DEMO:
                                    Print("Trade  : DEMO");
                                    break;
                        case ACCOUNT_TRADE_MODE_CONTEST:
                                    Print("Trade  : CONTEST");
                                    break;
                        case ACCOUNT_TRADE_MODE_REAL:
                                    Print("Trade  : REAL");
                                    break;

                        default:
                                    Print("Trade  : desconhecido");
            }


            Print("Conta $: " + AccountInfoString(ACCOUNT_CURRENCY));
            Print("Índice : " + _Symbol);



            

            if(!m_symbol.Name(_Symbol))
            {           return(INIT_FAILED);
            }


            double Minimo_Volume = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
            double Maximo_Volume = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);


            SaldoInicial    = AccountInfoDouble(ACCOUNT_BALANCE);


            Print("Contract_Size: ", SymbolInfoDouble(_Symbol, SYMBOL_TRADE_CONTRACT_SIZE));
            Print("Volume_Min: ", SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN));
            Print("Volume_Max: ", SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX));
            Print("Volume_Step: ", SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP));
            Print("Volume_Limit: ", SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_LIMIT));


            if(Volume_Moeda < Minimo_Volume)
            {           Volume_Moeda = Minimo_Volume;
            }




//---


            if(!Get_Saldo_Protegido())
            {           return(107);
            }


//---




            m_trade.SetExpertMagicNumber(m_magic);

            m_trade.SetDeviationInPoints(SlippageMaximo);

            m_trade.SetMarginMode();

            m_trade.SetTypeFillingBySymbol(m_symbol.Name());

            int digits_adjust = 1;

            if(Mercado != B3)
            {           if(m_symbol.Digits() == 3 || m_symbol.Digits() >= 5)
                        {           digits_adjust = 5;
                        }
            }

            double m_adjusted_point = m_symbol.Point() * digits_adjust;



            PoliDistancia = PoliRegr_MinDistancia * _Point;
            



            ChartSetSymbolPeriod(0, _Symbol, _Period);

            ChartRedraw(0);






            TimeToStruct(TimeCurrent(), Agora);

            ArraySetAsSeries(vela, true);

            return(INIT_SUCCEEDED);

}

 

It's hard to be sure as I don't use the Cloud myself. But I can see you are using a lot of custom indicators and my guess is the issue comes from there.

Also your code is adding indicators to a chart, but there is no chart in the Cloud.

                if(!ChartIndicatorAdd(0, subwindow, hCCI))
                {
                        PrintFormat("Falha em adicionar CCI (Commodity Index) na janela chart %d. Error code  %d", subwindow,GetLastError());
                        return(INIT_FAILED);
                }

You are also using custom return code :

            if(hCCI == INVALID_HANDLE)
            {           DisplayErroIndicator("Commodity Index");
                        return(105);
            }

But the documentation says :

For optimizing the EA inputs, it is recommended to use values from the ENUM_INIT_RETCODE enumeration as a return code. These values are intended for establishing the optimization process management, including selection of the most suitable test agents.

All of that should be checked carefully for a usage in the Cloud.

Documentation on MQL5: MQL5 programs / Testing Trading Strategies
Documentation on MQL5: MQL5 programs / Testing Trading Strategies
  • www.mql5.com
Testing Trading Strategies - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Alain Verleyen #:

It's hard to be sure as I don't use the Cloud myself. But I can see you are using a lot of custom indicators and my guess is the issue comes from there.

Also your code is adding indicators to a chart, but there is no chart in the Cloud.

You are also using custom return code :

But the documentation says :

All of that should be checked carefully for a usage in the Cloud.

Thank you Alain!

It's almost midnight here in Rio de Janeiro and tomorrow I'll take the custom code out of my EA.

But since I need INDICATORS to send me their signals, how can I use them without add them into a chart? I mean, to test my strategy do I need to change my entire EA?

Thank you for the help and tomorrow I'll see your comments. I NEED to sleep to work tomorrow...

Have a good night!

 
AliceRioBR #:

Thank you Alain!

It's almost midnight here in Rio de Janeiro and tomorrow I'll take the custom code out of my EA.

But since I need INDICATORS to send me their signals, how can I use them without add them into a chart? I mean, to test my strategy do I need to change my entire EA?

Thank you for the help and tomorrow I'll see your comments. I NEED to sleep to work tomorrow...

Have a good night!

Please note I am not sure exactly what is the problem as it's specific to the Cloud and I can't test (well I could technically but I don't want to pay for that of course).

You don't need an indicator to be visible on a chart to use it in your EA. It's useful only in Visual mode testing or on a live chart (and not mandatory even in this case). I would suggest you to make small test with some passes only to avoid wasting money. Try with a simplified version (maybe just one indicator) and check if it works, than add more to isolate the root of the problem.

 

Here is someone who had similar issue, also using a lot of custom indicators. But there was not really a solution provided.

https://www.mql5.com/en/forum/348493

 
Alain Verleyen #:

Here is someone who had similar issue, also using a lot of custom indicators. But there was not really a solution provided.

https://www.mql5.com/en/forum/348493

Thank you very much Alain!

I'll see it now.

I wish you all the best.

 
Alain Verleyen #:

Please note I am not sure exactly what is the problem as it's specific to the Cloud and I can't test (well I could technically but I don't want to pay for that of course).

You don't need an indicator to be visible on a chart to use it in your EA. It's useful only in Visual mode testing or on a live chart (and not mandatory even in this case). I would suggest you to make small test with some passes only to avoid wasting money. Try with a simplified version (maybe just one indicator) and check if it works, than add more to isolate the root of the problem.

It's a precious advice.

I'll try a very small test (just 2 or 3 passes).

Thanks a lot!

 

Dear Mr. Verleyen @https://www.mql5.com/en/users/angevoyageur


Basically, I performed the following modifications in my EA, without ANY success in executing it on Cloud Strategy Tester:


  • I changed all "custom return codes" for INIT_FAILED code.
  • I formally indicated each custom indicator in the #PROPERTY section of EA:

  • I disabled ALL indicators to be present on CHART
  • I also disabled references to BROKER, ACCOUNT, and any particular data of the account, using "defaults".
  • I set some data (as LEVERAGE and FREE BALANCE) to defaults (like USD 5,000 and so forth).


Really, it seems the CLOUD STRATEGY TESTER does not accept any custom indicator, since the error on the OnInit event still persists.

I thank you for your time and tips and, if it could be possible, send this message to some META ADMIN or (at least) put the message public to see if there is anyone that could answer me.

Kindest regards.




Cluod Strategy Tester: error 0 in line 1 and column 1?
Cluod Strategy Tester: error 0 in line 1 and column 1?
  • 2023.07.19
  • www.mql5.com
Hi! I enabled now the CLOUD STRATEGY TESTER and putting my EA to run there some tests I have the following error on all passes: 2023.07.18 21:53:22...
 

WOW !!!!

I GOT IT NOW!

It seems the problem was related to the above and two things I performed here:

1- LOG showed me that one of the indicators were in DEBUG mode - it didn't show it before, so, I believe it was because the presence of the CHART commands, blocking the code to continue until report this error.

2- I set ONLY ONE cloud (USA2) instead to allow other two clouds in Europe.


:D   THANK YOU SO MUCH ALAIN!

PS: After the test and a meeting I have now I'll help the guy by the above message (you posted) in try exactly what I did here.

Reason: