Trading Different Pairs With 1 Ea

 

Hi Everyone,

Great Forum ! If I have an EA which performs well on say the EUR/USD is there a way in the metatrader code using Symbol() that I can make it trade a different pair also say GBP/USD while the Expert is only attached to EUR/USD ? Eg: set the symbol to GBP/USD in the code ?

Any help would be appreciated !

 
leeb:
Hi Everyone,

Great Forum ! If I have an EA which performs well on say the EUR/USD is there a way in the metatrader code using Symbol() that I can make it trade a different pair also say GBP/USD while the Expert is only attached to EUR/USD ? Eg: set the symbol to GBP/USD in the code ?

Any help would be appreciated !

Check this section https://www.mql5.com/en/forum

It is very famous EA: TSD EA. Many versions are trading many pairs while you are attaching it to one pair only.

 

Hi NewDigital,

Thanks for your reply, I'll check that out.

I think it good be a good feature for any robust EA to trade other correlated currencies from 1 chart.

All the best & happy Christmas

 

Is there a piece of code that can easily be added to an EA to allow it to trade multiple pairs, without going into too much programming?

 

EA problem. Only 2 orders per currency.

Hi everyone. I'm here trying to find solutions for an EA of mine.

The idea of the EA is to run the same EA at the same time in different currencies. For example, EURUSD, CADJPY and EURGBP.

The EA must only execute 2 orders per currency and there cannot be 2 Sells or 2 Buys. If there are 2 orders in the currency they must be exclusively Sell and Buy.

I need the EA to look if the currency already has an order for example buy, if there is, don't put anymore orders of the same type and only allow 1 sell order.

Can anyone help me? i'll appreciate

 

...

Try using a function like this one :

int countOpenedOrders(string symbol, int type, int magicNumber=0)

{

int openedOrders = 0;

for(int i=0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;

if(symbol !="" && OrderSymbol() != symbol) continue;

if(magicNumber >0 && OrderMagicNumber() != magicNumber) continue;

if( OrderType() == type) openedOrders++;

}

return(openedOrders);

}

[/PHP]

An example to check EURUSD (regardless on the chart the EA is working at) for buy orders with no magic number :

if (countOpenedOrders("EURUSD",OP_BUY)==0) ... code for opening a ne buy order for "EURUSD"

or if you wish to check current symbol and your EAs magic number is 123456 for sell orders

[PHP] if (countOpenedOrders(Symbol(),OP_SELL,123456)==0) ... code for opening a new sell order for current symbol

___________________________________

PS: the total number of orders per symbol is implicit this way. If you allow only 1 buy and 1 sell, then you have the 2 orders per symbol too

wimpy63:
Hi everyone. I'm here trying to find solutions for an EA of mine.

The idea of the EA is to run the same EA at the same time in different currencies. For example, EURUSD, CADJPY and EURGBP.

The EA must only execute 2 orders per currency and there cannot be 2 Sells or 2 Buys. If there are 2 orders in the currency they must be exclusively Sell and Buy.

I need the EA to look if the currency already has an order for example buy, if there is, don't put anymore orders of the same type and only allow 1 sell order.

Can anyone help me? i'll appreciate
Reason: