How to count positions of symbol(s)
int Buys(const string& symbol) { int B=0,i; for ( i=0; i<PositionsTotal(); i++) { if ( symbol == PositionGetSymbol(i) && MagicNumber==PositionGetInteger(POSITION_MAGIC) && PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY ) { B++; } } return(B); }
or
int Buys(int index) { int B=0,i; for ( i=0; i<PositionsTotal(); i++) { if ( SymbolArray[index] == PositionGetSymbol(i) && MagicNumber==PositionGetInteger(POSITION_MAGIC) && PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY ) { B++; } } return(B); }

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 everyone, I'm designing a Multi-Symbol EA
and I tried to count every position of each symbol
method of symbol splitting
To count buy positions of each symbol
I wanted to use the same variable (j) on my conditions in OnTick
Where's my mistake?