"모든 제어 경로가 값을 반환하는 것은 아닙니다" 오류 - 페이지 2

 

안녕하세요 친구, 저도 같은 문제가 있습니다 누군가 나를 도울 수 있습니까?


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

관련 코드를 복사하여 붙여넣습니다. 이미지에서 함수 의 시작을 표시하지 않았으므로 반환해야 할 내용을 알 수 없습니다.

어쨌든 함수의 끝에 반환이 있어야 합니다.

 
  1. 이 포럼에 영어로 게시하십시오. 필요한 경우 자동 번역 도구 를 사용하십시오. 기계 번역 을 사용할 때 간단한 언어 구조를 사용하십시오.

  2. 코드 이미지를 게시하지 마십시오. 코드를 게시할 때 CODE 버튼(Alt-S)을 사용하십시오! (코드 양이 많을 경우 첨부해 주세요. ) (원본) 게시물을 수정 해주세요.
    포럼의 일반 규칙 및 모범 사례. - 일반 - MQL5 프로그래밍 포럼
    메시지 편집기

 
감사하고 죄송합니다. 모두 해결되었습니다.
 
Keith Watford :

Copie y pegue el codigo relatede. A partir de su imagen, no ha mostrado el comienzo de la función , por lo que no sabemos qué debería devolver.

모든 작업을 수행하고 기능을 최종적으로 사용할 수 있습니다.

안녕하세요 친구 이제 코드에 문제가 있음을 알 수 있습니까?

 
if(OrderSelect...
 
JermyRec :

이해가 안가는 친구


 
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)

중재자 : 다른 스레드에서 복사

 
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
}               

진행자 : 다른 스레드에서 복사한 Vitalii Anaev 의 회신

 

이중 게시하지 마십시오. 여기에서 답장을 받았는데 왜 정확히 같은 주제로 새 주제를 여세요. 이것은 단지 이기적이며 당신을 도우려는 사람들의 시간을 낭비합니다.

다른 주제를 삭제했습니다.