Having the strategy trade only once between 4 & 6 PM - page 2

 
jjc wrote >>

The check of "TimeHour(OrderOpenTime())<=hour_end)" allows trading until the end of hour_end (e.g. 18:59, not 18:00). Similarly, Roger's suggestion trades up until 06:59 (am, not pm).

Yes, that was my fault, I messed am and pm. But it's really till 6:00 not 6:59.

 

Just to say thx again, worked out for me.

After some more research I have found a very simple solution to reproduce what I was looking for:

   if (OrdersTotal()<=0)
    {  
     if (Hour()>=10 && Hour()<=13)
      {
       OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY);
       Print(OrderCloseTime());
       if(OrderCloseTime()<(TimeCurrent()-10*Period()*30))
       {

         Trade conditions here
         }}}  
   


This does effectively make the system trade only once during the interval I have selected, the sleep time being selecting with "10*Period()*30"

Thx and again and regards,

Inquisiteur