Download MetaTrader 5
To add comments, please log in or register
Publish your article and thousands of people all over the world will read it!
Ahmad Farhoud
11
Ahmad Farhoud 2015.03.28 17:10 

Hello,

I'm trying to make a break between each position. I want the EA to open position exactly after 10 minutes of the previous position closing . This can be easily  accomplished through Sleep() function but the problem is it doesn't work in strategy tester so i can never test this strategy automatically . So is there's any way to wait 10 minutes before opening  another position ? 

**Note : I use OrdersTotal() to check the number of opened positions , if it's 0 then it means the position is closed so I want to wait  10 minutes after having OrdersTotal() == 0 then I open another position

Rodrigo Malacarne
Moderator
9852
Rodrigo Malacarne 2015.03.28 21:24  
turndownforwhat:

Hello,

I'm trying to make a break between each position. I want the EA to open position exactly after 10 minutes of the previous position closing . This can be easily  accomplished through Sleep() function but the problem is it doesn't work in strategy tester so i can never test this strategy automatically . So is there's any way to wait 10 minutes before opening  another position ? 

**Note : I use OrdersTotal() to check the number of opened positions , if it's 0 then it means the position is closed so I want to wait  10 minutes after having OrdersTotal() == 0 then I open another position

Hello turndownforwhat,

You have to perform a for-loop on the orders history, in order to find the time of the last order (try to use HistoryOrderGetIntegerORDER_TIME_SETUP).

Then it will simple to compare the current time with the time of last opened order.

This is, IMHO, the best approach to do that.

Regards,
Malacarne

/
To add comments, please log in or register