Download MetaTrader 5

Opening a new order one day after last order (MT5)

To add comments, please log in or register
Chee Chua
661
Chee Chua  

Need some idea (MT5): 

How to allow opening of a new order only after the last order has be opened for at least more than one day?

Fstrifoerr8
36
Fstrifoerr8  
jon:

Need some idea (MT5): 

How to allow opening of a new order only after the last order has be opened for at least more than one day?

 1) Create global variable(or static) like bool new_trade=false;

2) Select last order

3) Chek current time-time of order. If it is more than 24*60*60 new_trade=true; else new_trade=false;  

Mary Clark
120
Mary Clark  

Do you also want to check a closed order ? If so 

 

datetime lastOrderClose = 0;

for(int iPos=OrdersHistoryTotal()-1; iPos >= 0; iPos--)
    if (  OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY)  // Only orders w/
    &&  OrderMagicNumber()  == Magic.Number             // my magic number
    &&  OrderSymbol()       == Symbol()             // and my pair.
    &&  OrderCloseTime() > lastOrderClose)
        lastOrderClose = OrderCloseTime();
if (TimeCurrent()-lastOrderClose > 24*60*60)
    new_trade = true;
else new_trade = false;
To add comments, please log in or register