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().
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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!