"Errore "Non tutti i percorsi di controllo restituiscono un valore - pagina 2

 

Ciao amici, ho lo stesso problema, qualcuno può aiutarmi?


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

Copia e incolla il codice corrispondente. Dalla tua immagine, non hai mostrato l'inizio della funzione, quindi non sappiamo cosa dovrebbe restituire.

Comunque ci deve essere un ritorno alla fine della funzione.

 
Grazie e scusate, è tutto risolto
 
Keith Watford:

Copia e incolla il codice pertinente. A partire dalla sua immagine, non ha mostrato l'inizio della funzione, per cui non sappiamo cosa debba essere devoluto.

In tutti i modi, deve esserci una devoluzione alla fine della funzione.

Ciao amico puoi vedere ora il problema che ha il codice?

 
if(OrderSelect...
 
JermyRec:

Non capisco amico


 
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)

Moderatore: copiato da un altro thread

 
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
}               

Moderatore: risposta diVitalii Ananev copiata da un altro thread

 

Non fare doppi post. Stavi ricevendo risposte qui, quindi perché aprire un nuovo argomento con esattamente lo stesso soggetto. Questo è solo egoista e spreca il tempo delle persone che cercano di aiutarti.

Ho cancellato il tuo altro topic.