for(int i=0; i<OrdersTotal(); i++){ if(OrderSelect(i, SELECT_BY_POS)){ if(OrderOpenTime() < iTime(Symbol(), PERIOD_H1, 48)){ // Open more than 48 hours OrderClose(OrderTicket(), OrderLots(), Ask, 3); } } }
Just an example for you. You need to change the Ask to Bid/Ask according to your OrderType().
Guan Chuan Lee:
Tysm it works perfectly!
Just an example for you. You need to change the Ask to Bid/Ask according to your OrderType().
So basically I'm trying to make the EA close a trade if it has been open for more than 48 hours. How would I do that?
Thank you!