Abnormal Termination Problem

 

Dear community.


I am absolutly sure the problem i am facing is caused by my own stupidity :).

Anyway i can not find a propper solution in my own brain, so i am here willing to learn from the wiser ones.


Let me start with my snippet here:

        for( int i=0 ; i < SymbolsTotal( false ) ; i++ ) {
        //for( int i=0 ; i < 50 ; i++ ) {

                string curr_name        = SymbolName(i, false);

                //copy all times into an datetime array
                datetime s_rates[];
                ArraySetAsSeries(s_rates,true);

                datetime        start_from      = ref_stamps[ArrayMinimum( ref_stamps, 0 , 0 )] - 7200  ,
                               copy_till       = TimeCurrent()                                                                                 ;

                CopyTime( curr_name , Period() , start_from , copy_till , s_rates );

                int has_stamp = 0;

                //      stop at numer one cauz this bar isnt finisched yet.
                for( int j = ArraySize( s_rates )-1 ; j > 1 ; j-- ) {

                        //      if our handled timestamp is smaller(older) than our oldest_target_stamp -> skip it
                        if( (int)s_rates[j] < oldest_target_stamp )
                                continue;

                        if( is_in_array( ref_stamps, (int)s_rates[j] ) )
                                has_stamp++ ;

                };

                //      create a bunch of symbols fitting our timeframes
                if( (int)ArraySize( ref_stamps ) == has_stamp ) {
                        str_to_array( qualified_symbols , curr_name) ;
                        Print( curr_name );
                        Sleep( 500 ) ;
                } else {
                        //      nasty shit but we need this. otherwise Kenny is dies with "abnormal termination".
                        Sleep( 500 ) ;
                };

        }; // close for all symbols


It has to copy many times of many symbols. After 50?100? it dies with abnormal termination. Sometimes a sleep of 500 or 1000 works, sometmes not. Do i have to free some arrays here? whats my fault? Is there a way to trap that error? "abnormal termination" is not very Verbose :)

I mql4 i did those stuff with iTime,IClose and so on without issues. But these days i want to migrate to mql5 broker.


Thanks for reading till that point here :)

derdigge

 
Your code is incomplete, no way to try it.
 

Thanks for reading :)


Just toggled it down to thisone. Create a new script and try this code:

int OnInit(){

        for( int i=0 ; i < SymbolsTotal( false ) ; i++ ) {

                string curr_name        = SymbolName(i, false);

                //copy all rates into an MQLarray - :) MQL5 feature
                datetime s_rates[];
                ArraySetAsSeries(s_rates,true);                                                                         ;

                CopyTime( curr_name , Period() , 0 , 5000 , s_rates );

                int has_stamp = 0;

                //      stop at numer one cauz this bar isnt finisched yet.
                for( int j = ArraySize( s_rates )-1 ; j > 1 ; j-- ) {
                                has_stamp++ ;
                };
                
                        Print( i );


        }; // close for all symbols
        
        return(INIT_SUCCEEDED);
};


It will lead into the same misery ......

 

okay there is an error, i added folling line for each ittertion:


Print( i , "  ", GetLastError() );


after some iteration it gives me errorcode 4401. I cant find this error code in documentation.

https://book.mql4.com/appendix/errors


Any thoughts?

Error Codes - Appendixes - MQL4 Tutorial
Error Codes - Appendixes - MQL4 Tutorial
  • book.mql4.com
Error Codes - Appendixes - MQL4 Tutorial
 

This is not the point here ....


int OnInit(){
   
   string qualified_symbols[];
   
        for( int i=0 ; i < SymbolsTotal( false ) ; i++ ) {

                string curr_name        = SymbolName(i, false);

                //copy all rates into an MQLarray - :) MQL5 feature
                datetime s_rates[];
                ArraySetAsSeries(s_rates,true);                                                                         ;

                int cp_res = CopyTime( curr_name , Period() , 0 , 5000 , s_rates );
                  
                if(cp_res==-1)
                  {
                   //   skip missing values.
                   continue;
                  }
                int has_stamp = 0;

                //      stop at numer one cauz this bar isnt finisched yet.
                for( int j = ArraySize( s_rates )-1 ; j > 1 ; j-- ) {
                                has_stamp++ ;
                };
                
                str_to_array( qualified_symbols , curr_name) ;
              

        }; // close for all symbols
        
        Print( ArraySize(qualified_symbols) );
        
        return(INIT_SUCCEEDED);
};

void str_to_array(string &handle_array[], string value) {

        int n_size = ArraySize( handle_array ) + 1 ;

        ArrayResize( handle_array, n_size );

        handle_array[n_size-1] = value ;
};


It crashes the same way. cpuload is very high when crash. I am skipping now the erroring copyrequests but still.

 
derdigge:

This is not the point here ....



It crashes the same way. cpuload is very high when crash. I am skipping now the erroring copyrequests but still.


It may be memory issue. Try to set the maximum bars to 1000 in the terminal options, then relaunch the terminal and run the script.

 

Thanks for your reply.


I monitored the memory usage in Windows tastkmanager and it didnt grow above 1000M for terminal.

Anyway i will try that now. Is there a limit terminal can use? Windows limit?


derdigge


EDIT: It seams You are on the right track. are there Methods to freeup memory? 

EDIT2: ArrayFree an ArrayResize of s_rates has no effect :/

 

You should really print each step of the way to see what's the last processed successfully processed.

Then the one that's next and that does not show up in the log is the problem.

I suspect the terminal freezes due to infinite loop.

Have you checked the windows logbook ?

What does the event viewer say about the crash ?

 
derdigge:

Thanks for your reply.


I monitored the memory usage in Windows tastkmanager and it didnt grow above 1000M for terminal.

Anyway i will try that now. Is there a limit terminal can use? Windows limit?


derdigge


EDIT: It seams You are on the right track. are there Methods to freeup memory? 

EDIT2: ArrayFree an ArrayResize of s_rates has no effect :/


No, there is no command to free memory for this purpose. Whenever you access other timeframe or symbol, an extra new chart buffer is allocated. The buffer gets released by timeout after a few minutes or replaced by a new one in case of rates refresh.

BTW, is your Windows system the 32-bit one?

 

@Marco vd Heijden.

I am not that fit with windows. where do i access a event viewer of windows? :)

Infinite loop is not the point here because when i just sleep 2000 each loop it works as ecxpected.


@ Ex Ovo Omnia

It is a windows 10 64bit profesional running in a kvm on my archlinux machine (Xeon E5 v4 - 128Gig Ram ). It has 8 Dedicated E5 Cores, and 8gigs of ram. I think this is enough.

 
derdigge:

@Marco vd Heijden.

I am not that fit with windows. where do i access a event viewer of windows? :)

Infinite loop is not the point here because when i just sleep 2000 each loop it works as ecxpected.


@ Ex Ovo Omnia

It is a windows 10 64bit profesional running in a kvm on my archlinux machine (Xeon E5 v4 - 128Gig Ram ). It has 8 Dedicated E5 Cores, and 8gigs of ram. I think this is enough.


I can't replicate your issue on build 1545 using inferior hardware, so I'm surmising your problem is being caused by the kvm.
Reason: