Set a delay timer between trades

 

Im wondering if its possible to set a delay timer between trades? I'm working on automating a strategy, but there are some times when conditions are met that trades will open and close faster then you can blink. I'm wondering if we can say "For the next 10 bars, do not open any new trades", or "For the next 60 minutes do not open any new trades"

Would really like someone's assistance if possible... thx

 

first u can use sleep()

second u can use timing for example (something like this)

int WaitTime = 10;  // 10 Min.
static int TimeSent;
if (TimeCurrent() >= TimeSent + (WaitTime * 60))
   {
   OrderSend(.....);
   TimeSent = TimeCurrent();
   }
else
   return(0);

or u can use bars option for example (something like this)

int WaitBars = 10;  // 10 Bars.
static int TimeSent;
int shift = iBarShift(NULL,0,TimeSent);
if (shift >= WaitBars)
   {
   OrderSend(.....);
   TimeSent = Time[0];
   }
else
   return(0);

didn't checked

& there r a lot more options

 
qjol:

first u can use sleep()

second u can use timing for example (something like this)

or u can use bars option for example (something like this)

didn't checked

& there r a lot more options


I love you. Thx ;)
 
Wooopa:

Ok...a new thought to add to this ...if you've got time it would be much appreciated.

> How would I pause trading after one bad trade for a period of say 1 'current' bars or 24hours for instance?

Thanks,

DAVID

Please don't double post . . .
 

I have add the same code to my EA (very simple only for testing) but I am missing something please can someone guide me.

I am getting the error  'return' - 'void' function returns a value.

Thankyou so much

 
micke81:

I have add the same code to my EA (very simple only for testing) but I am missing something please can someone guide me.

I am getting the error  'return' - 'void' function returns a value.

Thankyou so much


read about void function here
 
Kenneth Parling:

read about void function here


Many thanks for your reply.

Have changed the code and the error has gone. Thank you, but it is still sending orders every 20 seconds instead of 10mins. What have a done wrong.

Sorry if this is a easy mistake I am very new to this

 
interested to know how you went around th problem am having the same issue here
 
Marvelous Agbor:

<Deleted>

Do not double post.

I have deleted your other topic.

Post your code or nobody can help you.

Use the code button (Alt+S) when pasting code.

Edit: Post deleted as the code has been posted in another topic.

https://www.mql5.com/en/forum/367862#comment_22013757

Please i Need help i want to code a delay waiting seconds
Please i Need help i want to code a delay waiting seconds
  • 2021.04.23
  • www.mql5.com
let me say after lastclosedorder wait 15 seconds before open new trade so let me say a sell order and a but order is open when sell hit take profit...
 
Keith Watford:

Do not double post.

I have deleted your other topic.

Post your code or nobody can help you.

Use the code button (Alt+S) when pasting code.

Edit: Post deleted as the code has been posted in another topic.

https://www.mql5.com/en/forum/367862#comment_22013757

404. The page does not exist

Reason: