Pause after close order

 

My idea is make a some pause in EA after close order - but no Sleep.

It is section in line 38-57 in the atached file.   It work  well  in demo - but in optimalization i Tester   -  NO.

 Yet I could not find my mistake - problematic is maybe  instruction while ....

 

datetime time_Lo, time_Cu;                                     // čas do kdy čekat lokálně pro Comment a serveru pro podmínku
datetime TimeLocal, TimeCurrent;                               // časový okamžik do kdy bude pauza po uzavření obchodu  

bool IsOptimization;
bool IsTesting;
bool notester;                                                 // kontroluje stav Tester a Optimalizace         

notester = ( !IsOptimization() && !IsTesting());               // true while no-test AND no-optimalization


// test for CLOSE

bool total=OrdersTotal();  
    
    if (total>0)
    {  
      for(cnt=0;cnt<total;cnt++) 
        {
        if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))         continue;
// ########################################
         if ((OrderType()<=OP_SELL &&                   // check for opened position 
             OrderSymbol()==Symbol()                    // check for symbol
         &&  OrderMagicNumber()== Mag)==true)           // check magic number         
            { 
            
            Tre_SLP=((iCustom(NULL,0,"SlopeJB-i robot",period_SLP,2,0,0,0)             // fukction for condition
                       -iCustom(NULL,0,"SlopeJB-i robot",period_SLP,2,0,0,1))*Dig);              

            // close LONG
            if(OrderType()==OP_BUY) // long position is opened
              {
               // should it be closed LONG ? =====================================================
               if (Tre_SLP<0)
                    {
                     OrderClose(OrderTicket(),OrderLots(),Bid,Slip_page,Violet);             // close position 
   
                     
// .................... section for pause after closing  
                        
                        if (notester)                                                        // only no tester or no optimalization
                           {
                              time_Lo = (TimeLocal() + 2700);                                // wait for 45 minut (2700) after close - for Comment 
                              time_Cu  = (TimeCurrent() + 2700);                             // dtto for condition

                              while ( TimeCurrent() <= time_Cu ) 
                                 { 
                                    string EP = TimeToString (time_Lo, TIME_MINUTES);        // end  pause - čas konce pauzy pro Comment  
                                    
                                    Comment
                                       ("\n",
                                       " ||   PAUSE AFTER CLOSE until  ",EP,"  hours ");           
                                       
                                       Sleep(10000); PlaySound("tick.wav");                  // 10 sec akustic pause signal
                                       RefreshRates();
                                 }                          
                            }  
// .................... 
   
                     return(0); // exit
                    }

               // check for trailing stop
               
            // close SHORT

            

Files:
temp.mq4  4 kb
 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. buchtik: My idea is make a some pause in EA after close order - but no Sleep.
    Then why does your posted code have a sleep?
  3. buchtik: It work  well  in demo - but in optimalization i Tester   -  NO.
    'Testing Features and Limits in MetaTrader 4' - MQL4 Articles
 

To pause the Strategy tester whenever you need:

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

 

I am satisfied that the code is working well on the live and demo. This section I think has disabled for testing and optimalization.

 I don't need this break in the tester .   This condition is prohibited in tester but - is not working?  Why ?


If it is possible, I'm looking for a custom solution, which I can understand 

 

 

 

 

bool IsOptimization;
bool IsTesting;
bool notester;                                                 //          

notester = ( !IsOptimization() && !IsTesting());                 // true while no-test AND no-optimalization
..
.
.
 if (notester)                                                 // only no tester or no optimalization
        {
                  xxxxxxxxxxxxxx
        }
 

Don't declare the following. Remove it from your code. They are reserved internal functions of MQL4 which you are already using so don't declare them.

bool IsOptimization;
bool IsTesting;
 
enum Terminal_Mode{  MODE_LIVE, MODE_VISUAL, MODE_OPTIMIZER};
/// @returns terminal mode.
Terminal_Mode     get_modus_operandi(void){
   if(!IsTesting() )          return MODE_LIVE;
   if( IsVisualMode() )       return MODE_VISUAL;
                              return MODE_OPTIMIZER;
}
 
Thanks guys for new idea - i try it --- end refer the result .
 
FMIC:

Don't declare the following. Remove it from your code. They are reserved internal functions of MQL4 which you are already using so don't declare them.

You try It ???  I do it but .. undeclared identifier Compilator

 
buchtik:

You try It ???  I do it but .. undeclared identifier

"IsTesting()" and "IsOptimization()" are built-in functions. They have to be called with the "()". You must be calling them incorrectly in other places in your code which you have not shown us.

In the compile error list, it tells you which line is causing that problem, yet you have hidden that information from us. If you want us to help, then show us the full code, or in the very least the section identified by the compiler errors, otherwise we are unable to help you.