Hi coder, kindly help on my open order loop symbols count, kindly point out where I wrote wrongly ...
I've a multi-symbols EA and it can run 30 pairs. Let's say I've the following 4 symbols with open trades now :-
1) EURUSD : 2 BUY trades + 1 SELL trade
2) GBPJPY : 4 SELL trades
3) USDCAD : 3 BUY trades + 4 SELL trade
4) XAUUSD : 5 BUY trades
I plan to run a loop to detect how many symbols with open trades automatically, out of total of 30 symbols, for example, the output for "symCn" below should expect an answer of "4". My loop is as follows :-
Based on the above loop, it cannot give me the correct answers, could you please correct my codes so that the outputs :-
symCn=4 (4 symbols with BUY / SELL open trades)
bSymCn=3 (3 symbols with only BUY open trades)
sSymCn=3 (3 symbols with only SELL open trades)
Thanks.
I've a multi-symbols EA and it can run 30 pairs. Let's say I've the following 4 symbols with open trades now :-
1) EURUSD : 2 BUY trades + 1 SELL trade
2) GBPJPY : 4 SELL trades
3) USDCAD : 3 BUY trades + 4 SELL trade
4) XAUUSD : 5 BUY trades
I plan to run a loop to detect how many symbols with open trades automatically, out of total of 30 symbols, for example, the output for "symCn" below should expect an answer of "4". My loop is as follows :-
Inserted Code
int symCn=0, bSymCn=0, sSymCn=0; // Count how many symbols with OpOrd for(int i=SymbolsTotal(true)-1; i>=0; i--) { int sum=0, bSum=0, sSum=0; for(int j=OrdersTotal()-1; j>=0; j--) { if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==sym) { sum++; if(OrderType()==OP_BUY) bSum++; if(OrderType()==OP_SELL) sSum++;}} if(SymbolName(i,true)==sym && sum>0) symCn++; if(SymbolName(i,true)==sym && bSum>0) bSymCn++; if(SymbolName(i,true)==sym && sSum>0) sSymCn++; } Print("Sym# "+IntegerToString(symCn)+" / BUY Sym# "+IntegerToString(bSymCn)+ " / SEL Sym# "+IntegerToString(sSymCn));
Based on the above loop, it cannot give me the correct answers, could you please correct my codes so that the outputs :-
symCn=4 (4 symbols with BUY / SELL open trades)
bSymCn=3 (3 symbols with only BUY open trades)
sSymCn=3 (3 symbols with only SELL open trades)
Thanks.