trade certain time in different days

 

hello every one..

can the ea trade in certain time?

example:

monday, trade at time 15.00-18.00

tuersday, trade at time 10.00-14.00, 18.00-21.00

wed, trade at time 10.00-11.30, 13.30-17.00, 20.00-22.00

thu, trade all time

friday, non trade..


can it?

thx..

 
Yes, this is possble
 

example code please..

thx..

 

it's basically the same code as in every timefilter, you only will need a additional

switch(TimeDayOfWeek(Time[0])){

}

 
zzuegg:

it's basically the same code as in every timefilter, you only will need a additional

switch(TimeDayOfWeek(Time[0])){

}


And can EA trade in certain days of the month? For example last two days (buy) of prior month and close in the first two next month?
 

thx zzuegg, but i am using like this:

if ((DayOfWeek()==5 && Hour()==7 ) || (DayOfWeek()==3 &&  Hour()==9 || Hour()==10 || Hour()==11 || Hour()==15 || Hour()==17 )

it's can work..


sforma, if u want to close all position at next month, u can using this:

if (Day() ==1 && Hour()==0)
{
 int total = OrdersTotal();
  for(int i=total-1;i>=0;i--)
  {
    OrderSelect(i, SELECT_BY_POS);
    int type   = OrderType();

    bool result = false;
    
    switch(type)
    {
      //Close opened long positions
      case OP_BUY       : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
                          break;
      
      //Close opened short positions
      case OP_SELL      : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
                          break;

      //Close pending orders
      case OP_BUYLIMIT  :
      case OP_BUYSTOP   :
      case OP_SELLLIMIT :
      case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
    }
    
    if(result == false)
    {
      Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
      Sleep(3000);
    }  
  }
  }