paranthèses non équilibrées

 

Je n'arrive pas à trouver la bonne façon de mettre les crochets. Expliquez-moi quelle est mon erreur.

int start()
  { 
//----
   { 
   pending = ExistOrders(NULL);
   if (pending > 0 ) {return;}
   positions = ExistPositions(NULL);
   if (positions > 0 ) {return;}
   } else { 
   ticket=OrderSend(Symbol(),OP_SELL,0,1,Bid,3,Bid+20*Point,Bid-40*Point,"",magic,0,Red);}
   }
   
//----
   return(0);
  }
 
liana:

Je n'arrive pas à trouver la bonne façon de mettre les crochets. Expliquez-moi quelle est mon erreur.

parenthèses fermantes supplémentaires dans la ligne la plus longue
 
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);
}

vous pouvez le faire, mais alors le code prend plus de lignes :

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);
}

Vous pouvez aussi le faire de cette façon, mais il y a alors des inconvénients lors de l'édition :

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);
}

Par exemple, si vous souhaitez supprimer ou déplacer une ligne comportant une parenthèse ouvrante, vous devez effectuer des manipulations supplémentaires.

C'est pourquoi l'option 1 est meilleure.

 
ilunga:
crochet fermant supplémentaire dans la ligne la plus longue

Si je l'enlève, il est dit "crochet final attendu".
 
valenok2003:


J'ai copié ta version - elle dit à nouveau "paranthèses non équilibrées".
 
liana:

J'ai copié ta version et ça dit encore "paranthèses non équilibrées".

Oui, je vois, je vais arranger ça.
 
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);
}
 

Pour une raison quelconque, toutes vos options affichent "Fin de la fourchette attendue".

valenok2003:

vous pouvez le faire de cette façon, mais alors le code prend plus de lignes :

Vous pouvez aussi le faire, mais vous aurez alors des désagréments lors de l'édition :

Par exemple, si vous souhaitez supprimer ou déplacer une ligne comportant une parenthèse ouvrante, vous devez effectuer des manipulations supplémentaires.

C'est pourquoi l'option 1 est meilleure.

 

Voici tout le code. Peu importe comment je le corrige, le message "parenthèse finale attendue" ou "paranthèses non équilibrées" s'affiche.

Au secours, ça fait une heure que je me débats avec ces crochets.
Je veux vérifier les ordres ouverts et en attente, puis ouvrir un ordre.

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

int start() { 
//----
   pending = ExistOrders(NULL);
   if(pending = True ) return(0); // ???? ???????? ????????? ???????? ?????? ????? ?? ???????
   positions = ExistPositions(NULL);
   if(positions = True ) {
      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);
            }
          }
        }
      }
    }
  }
 

liana:

Voici le code complet. Peu importe comment je le corrige, le message "parenthèse finale attendue" ou "paranthèses non équilibrées" s'affiche.

Au secours, ça fait une heure que je me débats avec ces crochets.
Je veux vérifier s'il y a des ordres ouverts et en attente, puis ouvrir un ordre.


Votre dernière fonction ExistPositions n'est pas fermée. Et il n'y a pas de valeur de retour bool, ce qui est également une erreur. C'est-à-dire que si les conditions ne sont pas remplies, la fonction doit quand même retourner quelque chose.

Faites attention lorsque vous copiez des codes.

 
valenok2003:

Votre dernière fonction ExistPositions n'est pas fermée. Et il n'y a pas de valeur de retour bool, ce qui constitue également une erreur.
Merci (j'ai mal copié la fonction de Kim).
Maintenant, j'ai corrigé - à nouveau, il est écrit "parenthèse finale attendue".
int pending;
int positions;
int ticket;
int magic=576;

int start() { 
//----
   pending = ExistOrders(NULL);
   if(pending = True ) return(0); // ???? ???????? ????????? ???????? ?????? ????? ?? ???????
   positions = ExistPositions(NULL);
   if(positions = True ) {
      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);
Raison: