Programming question

hi everyone

I have a question for you, I would like to create a EA that will open max 1 order on every currency, but that can open many position on different currency. ex: never more than 1 position on eur-usd, but the EA could open 1 position on eur-usd, 1 on gbp usd, 1 on usdchf…

or if it’s easier: to take only 1 position at the time on a graph but can take more position with other graph?

do you know the programmation to do that?

thank you very much

The function return true if a trade is open with unique id and currency symbol
check the example below:

bool isTradeOpen(string curr, int unique_id, int ot=-1){
for(int pos=0; pos <= OrdersTotal(); pos++)
if( OrderSelect(pos, SELECT_BY_POS, MODE_TRADES) )
if( OrderSymbol() == curr)
if( OrderMagicNumber() == unique_id )
if( ot == -1 || OrderType() == ot)
if( OrderCloseTime() == 0 )
return(true);

return(false);

}

taking those positions is not too difficult for an ea, it is determining when, and then managing those trades as you wish that can be more complicated.
Can you be more specific about your requirements ?

Hi

It is more efficient to program an ea to manage only one pair, then you put that ea on each pair graphic you want to trade. Only thing you need is to have a different magic number for each pair if you want to manage them independently.
Think that to manage many currencies from one graphic will be very resource intensive and mq4 is not a very efficient language. Putting one ea for each currency will make one instance per pair and easier to handle.

Be careful with an ea. I wouldn’t only base trading off an ea.