OrdersTotal() is the count on all charts. You need to loop through the orders and count how many are on the current chart.
I recommend: Do not trade multiple currencies in one EA.
- You can't use any {MT4: predefined variables, MT5: predefined variables,}
- Must poll (not OnTick, unless you use specific indicators)
The Implementation of a Multi-currency Mode in MetaTrader 5 - MQL5 Articles 18 February 2011 - and usually other problems, e.g. A problem with iBarShift - MQL4 programming forum - Page 2
- You must handle History {MT4:4066/4073 errors: Download history in MQL4 EA - MQL4 programming forum, MT5: Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5.}
- Code it to trade the chart pair only. Look at the others if you must. Don't assume that Time[i] == iTime(otherPair, TF, i) always use iBarShift.
- Then put it on other charts to trade the other pairs. Done.
Thanks a lot!
Ready!
I solved everything with this function.
//+------------------------------------------------------------------+ //+ CONTAR OPERACIONES ABIERTAS EN CURRENT CHART + //+------------------------------------------------------------------+ int OPENOP () { int OpenOp = 0; for(int a=0; a<OrdersTotal(); a++) //busca todas las operaciones abiertas de la cuenta, si las hay. { if(!OrderSelect(a,SELECT_BY_POS,MODE_TRADES))continue; //selecciona las operaciones abiertas. if (OrderSymbol()==Symbol() && OrderMagicNumber()==magic) //verifica si pertenecen al gráfico actual. { OpenOp++; //obtiene la cantidad de operaciones abiertas del gráfico actual. } } //Cierre de "for" "a". return(OpenOp); }
I hope to help someone else.

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
I need to make my EA open a trade only when there is no other trade open on that same symbol, and I want to use the same EA on multiple symbols.
This is the filter that I placed to open operations, it works very well for me in 1 symbol, but when I want it to open operations in several symbols it does not.
The "OpenTrade ()" function contains the opening strategy, and I also limit the spread with which the trade will open.
Can you help me, please?