unbalanced parantheses - page 2

 

In any expression, make it a rule to end the string with the form elements first, and only then write the body.

For example, if you use an if statement, put an opening parenthesis and a closing parenthesis. If you put an opening curly bracket, place a closing one below it. When you write function, say, NormalizeDouble, put (,Digits); and then before the comma, write what you want to round. This way you will not make mistakes. And with time your eye will get used to it and you will immediately see these small details. If I can't find the error right away I cut out the independent parts of the code and compile it, the error is probably not in this part (if it is in two places), then I paste it back in. If some function is used and needs to be checked, cut out its contents and so on.

 
liana:
Thank you (I copied Kim's function wrong).
Now I corrected it - it says "ending bracket expected

there should be one more bracket after return(False); in the last function
 

Try to initially put a set of parentheses on a new line, and then enter what you need in them. And if several functions are nested in a "matryoshka", do not be lazy to indent each internal function by a couple of spaces and then there will be no more "missing" brackets :)

Function1()
{
  action1;
   Function2()
   {
     action2;
     action3;
   }
}
 

Fixed it - still something is wrong.
Could someone please just write me how it would be correct to call these two Kim functions and if there are no orders, to open an order.

int pending;
int positions;
int ticket;
int magic=576;

int start() { 
//----
   pending = ExistOrders(NULL);
   if(pending >0 ) return(0); // ???? ???????? ????????? ???????? ?????? ????? ?? ???????
   positions = ExistPositions(NULL);
   if(positions >0) {
      return(0);     // ???? ?? ???????? ???? ?????????
   }
   else { // else ????????? ? ?????????? if
      ticket=OrderSend(Symbol(),OP_SELL,0,1,Bid,3,Bid+20*Point,Bid-40*Point,"",magic,0,Red);
     
   }
//----
   return(0);
}
//+------------------------------------------------------------------+
//+----------------------------------------------------------------------------+
//|  Exist pending. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+

bool ExistOrders(string sy="", int op=-1, int mn=-1, datetime ot=0) {
  int i, k=OrdersTotal(), ty;
 
  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      ty=OrderType();
      if (ty>1 && ty<6) {
        if ((OrderSymbol()==sy || sy=="") && (op<0 || ty==op)) {
          if (mn<0 || OrderMagicNumber()==mn) {
            if (ot<=OrderOpenTime()) return(True);
          }
        }
      }
    }
  }
  return(False);
}

//+----------------------------------------------------------------------------+
//|  Exist open positions. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+

bool ExistPositions(string sy="", int op=-1, int mn=-1, datetime ot=0) {
  int i, k=OrdersTotal();
 
  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (ot<=OrderOpenTime()) return(True);
            }
          }
        }
      }
    }
  }
  return(False);
  }
 
liana:

Fixed it - still something is wrong.
Could someone please just write me how it would be correct to call these two Kim's functions and if there are no orders - open an order.


Parameters should be passed to the function, they are described in the function description

ExistOrders(string sy="", int op=-1, int mn=-1, datetime ot=0)

you should pass these parameters to the user function when calling it from start()

 
valenok2003:


parameters must be passed to the function, they are described in the function description

you must pass these parameters to the user function when calling it from the start() function


I don't need those parameters. I only need
2. Check for any position on the current chart symbol
ExistPositions(NULL);
But how to call this parameter correctly?

 
liana:


I don't need these parameters. I only need
2. To check availability of any position on current chart instrument
ExistPositions(NULL);
But how to call this parameter correctly?

do you need to check if there are any open positions?
 
liana:


I don't need these parameters. I only need
2. Check for any position on the current chart symbol
ExistPositions(NULL);
But how to call this parameter correctly?


Call it without parameters :

if(!ExistPositions()){// no open positions

if(!ExistOrders()){// no pending

 

I can't read it, my MetaEditor doesn't support the Russian encoding

 
liana:

I can't, MetaEditor doesn't support Russian encoding


Search his thread: https://www.mql5.com/ru/forum/107476, it's all there. From page 10 onwards, I think.
Reason: