Download MetaTrader 5
To add comments, please log in or register
No time to learn MQL5? The source code library is at your service!
Teeva Franssen
516
Teeva Franssen 2015.05.05 17:32 

Is there a script or  settings in metatrader once i put a buy or sell order, the order will execute for example 30 sec or 1 min later?

I am looking for a way to delay my order by a set amount of seconds 

Drazen Penic
2437
Drazen Penic 2015.05.05 18:56  
You can't do it without coding.
Teeva Franssen
516
Teeva Franssen 2015.05.05 19:30  
Drazen Penic:
You can't do it without coding.
So a coded script can be used?
Drazen Penic
2437
Drazen Penic 2015.05.05 19:52  

Yes, it can be done in two ways - using sleep function, where script starts and waits for given period, or using timer functionality where you can set time when will order be executed.

Sleep can be used in scripts, but timer needs expert advisor.

 

You should be aware that you can't be sure if order will be opened at exact time - there is network latency and brokers' server latency. I observed order opening times from half a second to two seconds in "normal conditions".  

Teeva Franssen
516
Teeva Franssen 2015.05.05 20:03  
Drazen Penic:

Yes, it can be done in two ways - using sleep function, where script starts and waits for given period, or using timer functionality where you can set time when will order be executed.

Sleep can be used in scripts, but timer needs expert advisor.

 

You should be aware that you can't be sure if order will be opened at exact time - there is network latency and brokers' server latency. I observed order opening times from half a second to two seconds in "normal conditions".  

Thanx for the reply

Where can i download the sleep script ? i cant find it in the codebase

Drazen Penic
2437
Drazen Penic 2015.05.05 20:18  

I am not sure there is such a script in the codebase.

Attached is one rudimentary script I wrote.

You can select buy/sell, set lot size and delay in seconds.

Drag & drop on the chart and it will open order with delay after you click button. 

Files:
Teeva Franssen
516
Teeva Franssen 2015.05.06 00:10  
Drazen Penic:

I am not sure there is such a script in the codebase.

Attached is one rudimentary script I wrote.

You can select buy/sell, set lot size and delay in seconds.

Drag & drop on the chart and it will open order with delay after you click button. 

Wouldn't this conflict with an EA already attached on the chart?
Drazen Penic
2437
Drazen Penic 2015.05.06 00:42  

This is a script.

You can run it even if you have EA or indicators on the chart.

Teeva Franssen
516
Teeva Franssen 2015.05.08 19:26  
Drazen Penic:

This is a script.

You can run it even if you have EA or indicators on the chart.

This script does not work.

 Attached to chart, when i click buy order its executed instantly. 

Drazen Penic
2437
Drazen Penic 2015.05.09 21:34  

You can't interfere with built in controls. If you click BUY on Metatrader button it will execute immediately and there is no any way to prevent this.

Script, I sent you, opens order delayed by given number of seconds.  

If you want to have delay you must use script or expert advisor that will delay order opening some time after you run it.

 

And, as I mentioned in above post - script is rudimentary, just an illustration of how it can be done.

/
To add comments, please log in or register