datetime - one minute one trade

 

Hi,


I try write the code with limitation of one trade per minute, but it doesn't work (perhaps problem is with logic). I tried many versions with break, Sleep(). Have anyone any suggestions?


thank you.


datetime mt=TimeCurrent();
 datetime mtoop=mt-PERIOD_M1*60;
   Print("mtoop==",mtoop);   // current time minus 1 minute, works
                                            
  for (int j=OrdersTotal()-1;j>=0;j--)
 {
  if (OrdersSelect(j,SELECT_BY_POS,MODE_HISTORY)
   if (OrderSymbol()==Symbol())
    {
      datetime z=OrderOpenTime();
       if (mtoop <z && z<mt) break;    // Sleep(60000) doesn't work
    }
 }
Reason: