Erro "Nem todos os caminhos de controle retornam um valor". - página 2

 

Olá amigos, eu tenho o mesmo problema, alguém pode me ajudar?


double price;
int    slippage;
double p = prce;
int    maxtry = RequoteAttempts;
color  CloseColor;

OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);

int ordtype = OrderType();
if (ordtype == OP_BUY) {price = NormalizeDouble(Bid,Digits); CloseColor = CloseBuyColor;}
if (ordtype == OP_SELL) {price = NormalizeDouble(Ask,Digits); CloseColor = CloseSellColor;}

if (MathAbs(OrderTakeProfit() - price) <= MarketInfo(Symbol(),MODE_FREEZELEVEL) * Point) return(0);
if (MathAbs(OrderStopLoss() - price) <= MarketInfo(Symbol(),MODE_FREEZELEVEL) * Point) return(0); 

if (OrderClose(ticket,OrderLots(),price,CloseSlippage,CloseColor)) return(1); 
if ((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146)) return(0); 

Print("Requote");

//--- RequoteAttempts) 

for (int attempt = 1; attempt <= maxtry; attempt++)
   {
   RefreshRates();
   if (ordtype == OP_BUY)
      {
      slippage = MathRound((Bid - p) / pp);
      if (Bid >= p)
         {
         Print("Closing order. Attempt " + (attempt + 1));
         if (OrderClose(ticket,OrderLots(),NormalizeDouble(Bid,Digits),slippage,CloseColor)) return(1);
         if (!((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146))) continue;
         return(0);
         }
      }
   if (ordtype == OP_SELL)
      {
      slippage = MathRound((p - Ask) / pp);
      if (p >= Ask)
         {
         Print("Closing order. Attempt " + (attempt + 1));
         if (OrderClose(ticket,OrderLots(),NormalizeDouble(Ask,Digits),slippage,CloseColor)) return(1);
         if ((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146)) return(0);
         
         }
      }
   }
}
 

Copiar e colar o código relevante. A partir de sua imagem, você não mostrou o início da função, portanto não sabemos o que ela deve retornar.

De qualquer forma, é necessário que haja um retorno no final da função.

 
Obrigado e desculpe, está tudo arranjado.
 
Keith Watford:

Copie y pegue el código relevante. A partir de sua imaginação, não há como mostrar o humor da diversão, por lo que não sabemos se deve devolver.

De todos os modos, debe haber una devolución al final de la función.

Olá amigo, você pode ver agora o problema que o código tem?

 
if(OrderSelect...
 
JermyRec:

Eu não entendo amigo


 
int CloseOrder(int ticket, double prce){ 
//+--------------------------------------------------------------------------------------------------------------+


double price;
int    slippage;
double p = prce;
int    maxtry = RequoteAttempts;
color  CloseColor;

OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);

int ordtype = OrderType();
if (ordtype == OP_BUY) {price = NormalizeDouble(Bid,Digits); CloseColor = CloseBuyColor;}
if (ordtype == OP_SELL) {price = NormalizeDouble(Ask,Digits); CloseColor = CloseSellColor;}

if (MathAbs(OrderTakeProfit() - price) <= MarketInfo(Symbol(),MODE_FREEZELEVEL) * Point) return(0);
if (MathAbs(OrderStopLoss() - price) <= MarketInfo(Symbol(),MODE_FREEZELEVEL) * Point) return(0); 

if (OrderClose(ticket,OrderLots(),price,CloseSlippage,CloseColor)) return(1); 
if ((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146)) return(0); 

Print("Requote");

//--- RequoteAttempts) 

for (int attempt = 1; attempt <= maxtry; attempt++)
   {
   RefreshRates();
   if (ordtype == OP_BUY)
      {
      slippage = MathRound((Bid - p) / pp);
      if (Bid >= p)
         {
         Print("Closing order. Attempt " + (attempt + 1));
         if (OrderClose(ticket,OrderLots(),NormalizeDouble(Bid,Digits),slippage,CloseColor)) return(1);
         if (!((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146))) continue;
         return(0);
         }
      }
   if (ordtype == OP_SELL)
      {
      slippage = MathRound((p - Ask) / pp);
      if (p >= Ask)
         {
         Print("Closing order. Attempt " + (attempt + 1));
         if (OrderClose(ticket,OrderLots(),NormalizeDouble(Ask,Digits),slippage,CloseColor)) return(1);
         if ((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146)) return(0);
         
        }  
      }
   }
}               In this line would be the error (')' - not all control paths return to value)

Moderador : Copiado a partir de outros fios

 
int CloseOrder( int ticket, double prce){ 
//+--------------------------------------------------------------------------------------------------------------+


double price;
int     slippage;
double p = prce;
int     maxtry = RequoteAttempts;
color   CloseColor;

OrderSelect (ticket, SELECT_BY_TICKET , MODE_TRADES );

int ordtype = OrderType ();
if (ordtype == OP_BUY ) {price = NormalizeDouble ( Bid , Digits ); CloseColor = CloseBuyColor;}
if (ordtype == OP_SELL ) {price = NormalizeDouble ( Ask , Digits ); CloseColor = CloseSellColor;}

if ( MathAbs ( OrderTakeProfit () - price) <= MarketInfo ( Symbol (), MODE_FREEZELEVEL ) * Point ) return ( 0 );
if ( MathAbs ( OrderStopLoss () - price) <= MarketInfo ( Symbol (), MODE_FREEZELEVEL ) * Point ) return ( 0 ); 

if ( OrderClose (ticket, OrderLots (),price,CloseSlippage,CloseColor)) return ( 1 ); 
if (( GetLastError () != 135 ) && ( GetLastError () != 138 ) && ( GetLastError () != 146 )) return ( 0 ); 

Print ( "Requote" );

//--- RequoteAttempts) 

for ( int attempt = 1 ; attempt <= maxtry; attempt++)
   {
   RefreshRates ();
   if (ordtype == OP_BUY )
      {
      slippage = MathRound (( Bid - p) / pp);
       if ( Bid >= p)
         {
         Print ( "Closing order. Attempt " + (attempt + 1 ));
         if ( OrderClose (ticket, OrderLots (), NormalizeDouble ( Bid , Digits ),slippage,CloseColor)) return ( 1 );
         if (!(( GetLastError () != 135 ) && ( GetLastError () != 138 ) && ( GetLastError () != 146 ))) continue ;
         return ( 0 );
         }
      }
   if (ordtype == OP_SELL )
      {
      slippage = MathRound ((p - Ask ) / pp);
       if (p >= Ask )
         {
         Print ( "Closing order. Attempt " + (attempt + 1 ));
         if ( OrderClose (ticket, OrderLots (), NormalizeDouble ( Ask , Digits ),slippage,CloseColor)) return ( 1 );
         if (( GetLastError () != 135 ) && ( GetLastError () != 138 ) && ( GetLastError () != 146 )) return ( 0 );
         
        }  
      }
   }
return(-1);/// not all branching code in the function return values
}               

Moderador : resposta deVitalii Ananev copiada de outro fio

 

Não postar duas vezes. Você estava recebendo respostas aqui, então por que abrir um novo tópico com exatamente o mesmo assunto. Isto é apenas egoísmo e desperdiça o tempo das pessoas que tentam ajudar você.

Eu apaguei seu outro tópico.