how Sleep() use? - page 2

 

thank you  

onewithzachy


Thank you very much from the heart. I was facing that the sleep function did not work with your last function. Now it working on the backtest,

but inside it it takes a variable of the type of int only, and I want to be delayed in hours or seconds.

What is the solution in your opinion?

onewithzachy
  • 2013.12.28
  • www.mql5.com
Trader's profile
 
Sebhy Kl #: I want to be delayed in hours or seconds.
onTick(){
   static datetime sleepTime=0;
   datetime now = TimeCurrent(); if(now < sleepTime) return;
   ⋮
   sleepTime = now + seconds; // Minutes*60 hours*3600;
}
 

William Roeder #

thanks


This is not accurate when I put 3600, which means that he should not open more than four trades on the four-hour chart, but he opens more than one trade in an hour sometimes.

William Roeder
William Roeder
  • www.mql5.com
Trader's profile
 
Sebhy Kl #: This is not accurate when I put 3600, which means that he should not open more than four trades on the four-hour chart, but he opens more than one trade in an hour sometimes.

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the file.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

We can't see your broken code.

 
My problem is that my Expertty succeeds when I run it in Control Point mode
But it fails when I turn it on Every tick mode
I concluded that the difference between them is only that the control point setting delays about seconds or minutes between executing the deals, so I am trying to find a function that sets a period between opening the deals and it works on the backtest and the real account
 

William Roeder

William Roeder

I made this code but it didn't work for delaying time between trades


    uint now =  GetTickCount();  

    long  orderticktime ;

       if (orderticktime <= now) 

    {

    if(OrderSelect (0,1,OP_BUY)){

    orderticktime =  GetTickCount()+10000;  // Ms + 10 Minuts

   }

.

.

.

}

 
Post your code as code.

GetTickCount returns milliseconds. 10000 are 10 seconds.


 
Sebhy Kl #: I made this code but it didn't work for delaying time between trades
  1. Please edit your post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. Of course, it doesn't work. Compare your declaration (orderticktime) to mine (sleepTime). There are two differences.