halt trading for 3 bars of last closed position

 

I'm working on EA.

and want to start trading only after 3 bars from last closed order.

in other word, once order closed, i want the trading to be halted for 3 bars.

is it possible to do that?

 

 
     for(int lco=OrdersHistoryTotal(); lco=0; lco--)
       {
        if(OrderSelect(lco, SELECT_BY_TICKET, MODE_HISTORY))
        continue;
        if(OrderCloseTime()+(Period()*3)>TimeCurrent()) return(0);
        
             }

This is the code I made so far. Please advise if it is correct or not.

 

I made it. Here is the code in case any one would need this. 

 

   int lastOrderCloseTime;
     for(lco=OrdersHistoryTotal()-1; lco >= 0; lco--)
       {
        if(OrderSelect(lco, SELECT_BY_POS, MODE_HISTORY) 
        && OrderMagicNumber() == 16384 
        && OrderSymbol() == Symbol() 
        && OrderType() <= OP_SELL 
        && OrderCloseTime () > lastOrderCloseTime)
        {
        lot=OrderTicket();
        lastOrderCloseTime = OrderCloseTime();
        }}
   if(total<1 && (lastOrderCloseTime+(PeriodSeconds()*3))<TimeCurrent())
    {
....
}

 Special thanks goes to WHRoeder for the code provided here https://www.mql5.com/en/forum/138894

selecting last closed order, from History (doh!) - MQL4 forum
  • www.mql5.com
selecting last closed order, from History (doh!) - MQL4 forum
Reason: