I can count for a currency by using following code;
int Trade::Count(int type)
{
int count=0;
for(int i=0; i<=OrdersTotal()-1; i++)
{
bool Select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(Select && OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber && OrderType()==type) count++;
}
return (count);
}
However, this code for a currency. not for total currencies.
int Trade::CountTotal() { int count=0; for(int i=OrdersTotal()-1; i>=0; i--) { bool selected=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(selected && OrderMagicNumber()==MagicNumber) count++; } return (count); }This counts all open orders belonging to this EA. So before opening a new order the EA could check whether this count has reached a limit (MaxOpenTrades or so.)
lippmaje:
This counts all open orders belonging to this EA. So before opening a new order the EA could check whether this count has reached a limit (MaxOpenTrades or so.)
This counts all open orders belonging to this EA. So before opening a new order the EA could check whether this count has reached a limit (MaxOpenTrades or so.)
Thank you so much!
This was interesting. I will definitely try it. :-)

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
Hi all,
I have an EA. It runs on 5 currencies (eurusd, gbpusd, usdchf, usdcad, and, audusd).
When the EA has a trade or sometimes trades on a currency forexample on eurusd, it must not open trades on the other currencies.
How can I code that?
Best.
Or,
How can I manage total trades for above currencies. Forexample, I want to allow max. 6 trades at the same time in totally (for all currencies).