stop ea after excute a trade

 
i want to stop ea for 10 minutes everytime the ea enter a trade, is there any way to do that beside using sleep() ?
 
ddock:
i want to stop ea for 10 minutes everytime the ea enter a trade, is there any way to do that beside using sleep() ?

Why would you want to do anything else? - sleep(600000) is absolutely the correct way to achieve this.

 
cloudbreaker:

Why would you want to do anything else? - sleep(600000) is absolutely the correct way to achieve this.

Sleep(x) is definitely the correct way to achieve this if you absolutely literally want to stop the EA for 10 minutes after trading - i.e. stop all execution whatsoever. But it's not the answer if "stop EA for 10 minutes" means "don't place any further new trades, but do monitor profitability on existing trades and potentially change stop-losses etc."


If the latter, then you simply need to record the last time you entered a trade in a static or global variable, and then not allow yourself to enter a new trade while within 10 minutes (or whatever) of that time. A very simple partial example would be something like the following:


int start()

{

   static int TimeOfLastTrade = 0;

   

   // Potentially place new trades

   if (TimeLocal() - TimeOfLastTrade >= 600) // 60 seconds times 10 minutes

   {

      // More than 10 minutes from previous trade.

      // New trades now allowed. When placing a 

      // trade, record the time using:

      //   TimeOfLastTrade = TimeLocal();


   } else {

      // New trades not allowed

   }


   // Monitor profitability of existing trades, on every tick


   [etc...]