Where is the correct place to put the SLEEP FUNCTION

 

Hi,

it looks i am struggling to find the answer. Searched over and over, but with no success.

I have same EA running on two charts EURUSD,same period. I need the second EA to execute trade with 20 secs delay from the first one.

I use:

void  Sleep(
   int  20000      // interval
   );

1.Is it correct?

2.Where is the correct place to paste the function code?

3.Should i just save it or compile it?


Many thanks,

 
zlattin2000:

I have same EA running on two charts EURUSD,same period. I need the second EA to execute trade with 20 secs delay from the first one.

Sleep() is usually not the best option with MT5.

Could you use the OnTimer() event to place the trade in 20 seconds?

 
Anthony Garot:

Sleep() is usually not the best option with MT5.

Could you use the OnTimer() event to place the trade in 20 seconds?

Sorry, forgot to mention it is EA running on MT4.
 
zlattin2000:

Do not double post.

I have deleted your other topic and will move this to the mql4 sub-forum.

 
  1. zlattin2000:  Sorry, forgot to mention it is EA running on MT4.
    Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. zlattin2000: I have same EA running on two charts EURUSD,same period. I need the second EA to execute trade with 20 secs delay from the first one.
    They both received the same tick and have decided to open. Why do you think you need a sleep?
 
William Roeder:
  1. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. They both received the same tick and have decided to open. Why do you think you need a sleep?

too late i saw it is MT5 section, sorry. Anyway, i need that delay 20 secs as i am sending signals to ZuluTrade and there should be a time gap between two positions in order to be copied.

Thanks

 
Keith Watford:

Do not double post.

I have deleted your other topic and will move this to the mql4 sub-forum.

Sorry to trouble you Keith, next time i will post in the correct sub-forum.
 
zlattin2000 i need that delay 20 secs as i am sending signals to ZuluTrade and there should be a time gap between two positions in order to be copied.

You have the code. Drop the second EA. Have the first send two orders. What's the problem?

 
William Roeder:

You have the code. Drop the second EA. Have the first send two orders. What's the problem?

and what is the code to make EA to open two same orders with 20 secs delay between?
 
zlattin2000:  and what is the code to make EA to open two same orders with 20 secs delay between?
You already know. It's in your title.
  1. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
  2. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help