int CountCurrentOrders(string symbol, int magic) { int buys=0, sells=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic) { if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++; } } //---- return orders volume return(buys+sells); }
I guess this is what you basically want to do. (Minor adjustments necessary).
Markus

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
On the metaquotes.net site there used to be a MQL II code for trading multiple charts with one expert advisor. I can’t seem to find the old FAQ MQL II or a replacement for the new MT4.
The old code was:
for cnt=1 to TotalTrades //count opened order ,a pair currency only one trade
{
if (OrderValue(cnt,VAL_SYMBOL)= Symbol) then tradecnt = tradecnt+1 ;
}; // End of for cnt=1 to TotalTrades
if tradecnt<1 then
Is there any one smarter than me (witch is 99.9% of the world population) who can convert this MQL II code to MQ4.
Thank you in advance.