extern int LimitPerPair=5; int NumberOfTrades=0; for(int i=1; i<=OrdersTotal(); i++) // Cycle searching in orders { if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available { if(OrderSymbol()==Symbol()) { NumberOfTrades++; } } } if(NumberOfTrades>=LimitPerPair) bool DontTrade=true; if(...&&DontTrade!=true) { // trade }Untested but it should give you an idea
Usually I do something to the effect of:
int _countOpenOrders(int countOpen = 0) { for(int x=0; x<=OrdersTotal(); x++) if( OrderSelect(x, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == Magic.Number && OrderSymbol() == Symbol() && OrderType() == OP_SELL || OP_BUY) // Whatever orders you use countOpen++; return(countOpen); }
thank you very much. you have answered me. I will try it to see if it works.
No problem, glad we could help.
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
How Can one restrict a number of open position par pair?