My function to close all positions does not work properly

 

I created this function and as long as I do backtesting using [OHCL 1 MINUTE] it works correctly, but when I use [EVERY TICK] some error messages like the following appear (warning, not error):

2019.04.26 16: 00: 26.351 Core 1 EURUSD: 2017.06.05 00:01 - 2017.06.05 23:59 18 minute bars absent within a day while real ticks present

then the ea fails to send some orders [invalid price] and the function for closing all open positions does not work properly (some trades remain open)

for (int conta=PositionsTotal()-1; conta>=0; conta--)
        {
         ulong  PositionTicket=PositionGetTicket(conta);
         string symbol=PositionGetString(POSITION_SYMBOL);
         ulong magic=PositionGetInteger(POSITION_MAGIC);
         if (Symbol()==symbol && magic==EA_MagicNumber)
           {
            trade.PositionClose(PositionTicket);
           }
        } 

if someone could help me to PREVENT these errors i would be grateful :)

 
There is nothing to prevent.
  1. There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific.) requires knowledge of when your broker stops and starts (not necessary the same as the market.)
              "Free-of-Holes" Charts - MQL4 Articles
              No candle if open = close ? - MQL4 and MetaTrader 4 - MQL4 programming forum

  2. Your posted code doesn't send orders.
  3. There are no errors posted.
 
William Roeder:
There is nothing to prevent.
  1. There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific.) requires knowledge of when your broker stops and starts (not necessary the same as the market.)
              "Free-of-Holes" Charts - MQL4 Articles
              No candle if open = close ? - MQL4 and MetaTrader 4 - MQL4 programming forum

  2. Your posted code doesn't send orders.
  3. There are no errors posted.
Thanks
Reason: