string symbols[]={"EURUSD","GBPUSD","AUDUSD","USDJPY"}; //--- OrdersCloseByTimer(4.5,symbols); //--- bool OrdersCloseByTimer(double hours,const string &symbol[]) { int total=OrdersTotal(); int size=ArraySize(symbol); int maxDuration=int(hours * 3600); //--- for(int pos=total-1;pos>=0;pos--) for(int i=0;i<size;i++) { if(OrderSelect(pos, SELECT_BY_POS) && OrderType()<=OP_SELL // Only my orders w/ && OrderSymbol()==symbol[i]) // period and symbol { int duration=int(TimeCurrent()-OrderOpenTime()); if(duration>=maxDuration) if(!OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(),30)) return(false); } } //--- return(true); }
Thank you so much for helping me out Ernst.
I am seeing an error on the line below,
OrdersCloseByTimer(4.5,symbols);
'OrdersCloseByTimer' - declaration without type
Sizzles:
Thank you so much for helping me out Ernst.
I am seeing an error on the line below,
'OrdersCloseByTimer' - declaration without type
It has to be placed in the start() function.
string symbols[]={"EURUSD","GBPUSD","AUDUSD","USDJPY"}; //--- int init() { //---- //---- return(0); } //--- int start() { OrdersCloseByTimer(4.5,symbols); //--- return(0); }
Hi I have the same code for mt5?

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
Hello PPL,
I was hoping one of you wise coders could help me out here.
I need a timer expert that will automatically close trades, across multiple currency pairs after each trade has been open for 4.5 Hours.
I found the script below over at https://www.mql5.com/en/forum/130018 which is nice but it only works for one pair.
Can any of you modify it to work on multiple pairs please?