Putting a delay between closing and opening of trades - page 2

 

Thanks DeVries....Thanks for the idea...Since I have to put the interval between trades of the same symbol, I think I have to traverse the history. What do you say?

However, I am not sure if after closure, the closed tarde is available in the history pool that quickly.. 

 
LongJohnSilver:

Thanks DeVries....Thanks for the idea...Since I have to put the interval between trades of the same symbol, I think I have to traverse the history. What do you say?

However, I am not sure if after closure, the closed tarde is available in the history pool that quickly.. 


Every closed trade is to find the moment it is closed in OrdersHistoryTotal() 
 
LongJohnSilver: when a trade is closed, I would like to open the new trade with a 15 seconds interval. 

bool     MySelect(int iWhat, int eSelect, int ePool=MODE_TRADES){
   if(!OrderSelect(iWhat, eSelect, ePool) )  return (false);
   if(OrderMagicNumber() != magic.number  )  return (false);
   if(OrderSymbol()      != symbol.chart  )  return (false);
   if(ePool != MODE_HISTORY               )  return (true);
   return(OrderType() <= OP_SELL);  // Avoid cr/bal forum.mql4.com/32363#325360
                                    // https://forum.mql4.com/30708
                                    // Never select canceled orders.
}
int      MyOrdersTotal(int op=-1, int ePool=MODE_TRADES){   #define OP_ALL -1
    if(ePool == MODE_TRADES)     int    iPos = OrdersTotal()      - 1;
    else                      iPos = OrdersHistoryTotal() - 1;
    for(int nOrders=0;; iPos >= 0; iPos--) if(
       MySelect(iPos, SELECT_BY_POS, ePool)) if(
       op == OP_ALL || op == OrderType()
    )  nOrders++;
   return(nOrders);
}
int start(){
   int ooc = MyOrdersTotal();
   static datetime oct;
   if (ooc > 0){ oct = TimeCurrent(); return; } // open order
   if (oct + 15 > TimeCurrent()) return;
   // order close time more than 15 seconds ago.
 
I am extremely thankful to RaptorUK, deVries and WHRoeder...Your comments/remarks/suggestions/code-snippets have been very very helpful. Thanks a million.
Reason: