Stop My EA untill next Day when i have reach two winner consecutive or losses Trade

 

Hi 

I have my two Count Function to Winner trade and to Losses Trade 

But I want to know if is possible modify the Count Function to do this if I have two Losses or Winner consecutive trade 

and if is DayOfTheWeek ()==1 , and  Next Session trade is  DayOfTheWeek ()==2 The Count, ComeBack to 0 and my 

Condition Function Start To Work Again day by day

I show you My Condition that work fine but if get two win o losses trade the EA don't work more

 //double D_line=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,1);
 //double Pre_K_line= iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,2);
// double Pre_D_line=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,2);

 
  if( Losses()<2  &&Winner()<2 && TotalOpenOrders()<1)
 if(MA1>MA2)
 if(Close[1]>MA1)
 Compra();
 
  /////////////////
  
   if( Losses()<2  &&Winner()<2 && TotalOpenOrders()<1)
   if(MA1<MA2)
   if(Close[1]<MA1)
   Venta();
  }
 ///////////////////////

then I want to modify the Count Function to do this if I have two Losses or Winner consecutive tradeand if is DayOfTheWeek ()==1 , and  Next Session trade is  DayOfTheWeek ()==2 The Count, ComeBack to 0

Like this

int Winner()
  {
   
    int Contador = 0;
    for(int i=OrdersHistoryTotal()-1; i>=0; i--)
    {
      OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(OrderProfit()<0) break;
      Contador++;
        
      /////Something Like THIS //////
      if(Contador==2 && DayOfWeek()==1)
     
     /// I want to do that if(DayOfWeek()==2 then Contador ==0///
     /// I dont know if is posible ?////
              
      {
   int Current_Time = TimeHour(Time[1]);
   if Current_Time >= Start_Trade_Hours && Current_Time <Start_Trade_Hours)return(true);
   else return(false); 
     }              
 }
  
    return(Contador);
  }


I need Help What I have to do, which is the easier or What ?

 

Looking at your code, I suggest making use of OrderCloseTime(), TimeDayOfYear() and DayOfYear() functions will be neater, as follows (code segment that could go inside the "for" loop of your Winner() function): 

  OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
  datetime T = OrderCloseTime();

  if (TimeDayOfYear(T)!=DayOfYear()) //since the last order was closed on a different day, there is no need to check further.
    break;

  if (OrderProfit()<0) //with the above time check, you can continue to check for the 2nd last order as well.
    continue;
  else
    Contador++;

  if (Contador==2)
    break;

as for the checks to make sure that the current time is within the Trade Hours, I think they can go into a separate function, or included in your main code body. Also, do check that "Current_Time >= Start_Trade_Hours && Current_Time <Start_Trade_Hours" is erroneous.

 
Seng Joo Thio:

Looking at your code, I suggest making use of OrderCloseTime(), TimeDayOfYear() and DayOfYear() functions will be neater, as follows (code segment that could go inside the "for" loop of your Winner() function): 

as for the checks to make sure that the current time is within the Trade Hours, I think they can go into a separate function, or included in your main code body. Also, do check that "Current_Time >= Start_Trade_Hours && Current_Time <Start_Trade_Hours" is erroneous.

Joo Thio Thanks a lot