MickGlancy:
I want the EA to count how many open and pending orders of each type
I want the EA to count how many open and pending orders of each type
#define OP_COUNT OP_SELLSTOP+1 int count[OP_COUNT]; ArrayInitialize(count,0); for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() ){ // and my pair. count[OrderType()]++; } Print("I have ",count[OP_BUY]," buys");
WHRoeder:
thank you very much WHRoeder
what does [ #define OP_COUNT OP_SELLSTOP+1 ] mean ?

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
Im a newbie and Im really stuck, I had tried many ways and combined with my programming inexperience, I just cant find a solution to this problem.
I want the EA to count how many open and pending orders of each type are on the account, and store the result for each type in a variable. I have this code
really I am asking how to do it with SWITCH. I can achieve it with lots of nested "if" but if SWITCH could be cleaner code, that would be great :-)
thankyou