Download MetaTrader 5

How to limit EA to open only one position in specific currency pair

To add comments, please log in or register
Join MQL5 Cloud Network. Start earning money!
franko
53
franko 2014.06.12 15:55 

Hello,

Does anyone have code for this? By searching google in previous topics I found something like this but it doesn't seem to work:

for (int k = 0; k < OrdersTotal(); k --) 
   {
      OrderSelect(k, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) 
      {
        if(OrderType() == OP_BUY) 
         {   


Best regards,

Roberts

whroeder1
14470
whroeder1 2014.06.12 18:10  
Franko: like this but it doesn't seem to work:
for (int k = 0; k < OrdersTotal(); k --){
  OrderSelect(k, SELECT_BY_POS);
  1. Of course it doesn't work. You start at zero, check for going too high, and then go lower.
  2. What are Function return values ? How do I use them ? - MQL4 forum
  3. Count first and then decide. See https://www.mql5.com/en/forum/145507
To add comments, please log in or register