# Managing positions of multiples EA

Hello

I'm building multiples EA for EURUSD, but there are some conflicts when they open a posiition.

How can I filter to see if my current EA with magic number x have a open position?

PS: There are more than 3 EA's. I didnt put all together because I wont be able to backtest.

```    if(temosNovaVela && PERIOD_D1 && (saberMesAno(TimeCurrent()) != 6))
{
Comprar = compra_EURUSD_D1;
Vender = venda_EURUSD_D1;
if(Comprar && PositionSelect("EURUSD") == true)
{
for(int i=0;i< PositionsTotal();i++)
{
if(PositionGetTicket(i)>0 && PositionGetInteger(POSITION_MAGIC) == magic_number)
{
break;
}
}
desenhaLinhaVertical("Compra",velas[1].time,clrBlue);
}```
Testing trading strategies on real ticks
• www.mql5.com
The article provides the results of testing a simple trading strategy in three modes: " 1 minute OHLC " using only Open, High, Low and Close prices of minute bars; detailed modeling in " Every tick " mode, as well as the most accurate " Every tick based on real ticks " mode applying actual historical data. Comparing the results allows us to...

"How can I filter to see if my current EA with magic number x have a open position?"

Your code is already doing that: loop over all open positions and filter by magic number. Then count the number of open positions which have this magic number. If the total quantity is larger than zero you have an open position. You can also create the sum of the total position size to see whether you are long, short, or flat.

Jhonatan Breia Carvalho Maia :

Hello

I'm building multiples EA for EURUSD, but there are some conflicts when they open a posiition.

How can I filter to see if my current EA with magic number x have a open position?

PS: There are more than 3 EA's. I didnt put all together because I wont be able to backtest .

I strongly recommend against using PositionSelect .

This is an example of an Expert Advisor that calculates positions BY CURRENT SYMBOL and by TASKED Magic number.

Documentation on MQL5: Trade Functions / PositionSelect
• www.mql5.com
Chooses an open position for further working with it. Returns true if the function is successfully completed. Returns false in case of failure. To obtain information about the error, call GetLastError(). If individual positions are allowed (ACCOUNT_MARGIN_MODE_RETAIL_HEDGING), multiple positions can be open for one symbol. In this case...