"Tüm kontrol yolları bir değer döndürmez" hatası - sayfa 2

 

Merhaba arkadaşlar bende de aynı sorun var yardımcı olabilecek var mı?


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

İlgili kodu kopyalayıp yapıştırın. Resminizden, işlevin başlangıcını göstermediniz, bu yüzden ne döndürmesi gerektiğini bilmiyoruz.

Her neyse, fonksiyonun sonunda bir dönüş olması gerekiyor.

 
  1. Lütfen bu forumda İngilizce yayınlayın. Gerekirse otomatik çeviri aracını kullanın. Mekanik çeviriyi kullanırken basit dil yapısını kullanın.

  2. Lütfen kodun resmini göndermeyin. Kod gönderirken lütfen KOD düğmesini (Alt-S) kullanın! (Büyük miktarda kod için ekleyin. ) Lütfen (orijinal) gönderinizi düzenleyin .
    Forumun genel kuralları ve en iyi uygulamaları. - Genel - MQL5 programlama forumu
    Mesaj Editörü

 
Teşekkürler ve üzgünüm, hepsi düzeltildi
 
Keith Watford :

Konuyla ilgili kopyalayın. Bir partir de su imagen, no ha Mostrado el comienzo de la función , por lo que hiçbir sabemos qué debería devolver.

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

Merhaba arkadaşım şimdi kodun sahip olduğu sorunu görebiliyor musunuz?

 
if(OrderSelect...
 
JermyRec :

anlamıyorum arkadaş


 
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)

Moderatör : Başka bir başlıktan kopyalandı

 
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
}               

Moderatör : Vitalii Ananev'in cevabı diğer başlıktan kopyalandı

 

Çift gönderi yapmayın. Burada cevaplar alıyordunuz, neden tamamen aynı konu ile yeni bir konu açıyorsunuz. Bu sadece bencilcedir ve size yardım etmeye çalışan insanların zamanını boşa harcar.

Diğer konunuzu sildim.