실수로 고통받는 거래가 없습니다. - 페이지 9

 

코드를 수정하고 테스터에서 실행했습니다.

 #property version    "1.00"
#property strict

int test_ticket[ 2 ]={ 0 , 0 };
double    gl_lots,
         gl_ask,
         gl_bid;
string    gl_comm;         
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit () {
//---

//---
   return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason) {
//---

}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick () {
   gl_lots= SymbolInfoDouble ( _Symbol , SYMBOL_VOLUME_MIN );
   gl_ask= NormalizeDouble (Ask, _Digits );
   gl_bid= NormalizeDouble (Bid, _Digits );
   gl_comm= "test" ;
//---
   if (AccountFreeMarginCheck( _Symbol ,OP_BUY,gl_lots)<= 0 || GetLastError ()== 134 ) {
       printf ( "Not enough money for the minimum lot: %.4f" ,gl_lots); 
       return ;
   }
   if (test_ticket[ 1 ]< 8 && test_ticket[ 0 ]== 0 ) {
      test_ticket[ 0 ]= OrderSend (( StringCompare ( _Symbol , "NZDUSD" )== 0 ? "NZDUSD" : _Symbol ),OP_BUY,gl_lots,gl_ask, 30 , 0.0 , 0.0 ,gl_comm, 33333 , 0 , clrNONE );
       if (test_ticket[ 0 ]> 0 ) test_ticket[ 1 ]++;
       else if (Fun_Error( GetLastError ())== 1 ) return ; 
   }   
   if (test_ticket[ 0 ]> 0 )
       if ( OrderSelect (test_ticket[ 0 ],SELECT_BY_TICKET)) {
         if (OrderCloseTime()== 0 && OrderOpenTime()+ 300 < TimeCurrent ())
             if (OrderClose(test_ticket[ 0 ],OrderLots(),gl_bid, 30 , clrNONE )) {
               printf ( "Test order closed, ticket #%d" ,test_ticket[ 0 ]);
               test_ticket[ 0 ]= 0 ;
            } else if (Fun_Error( GetLastError ())== 1 ) return ;
      } else if (Fun_Error( GetLastError ())== 1 ) return ;
}
//+-------------- ФУНКЦИЯ ОБРАБОТКИ ОШИБОК ---------------------------------+
int Fun_Error( int Error)
{  
   switch (Error)
   {
         case 0 :       return ( 0 );
         case 1 :       Print ( "Trying to change already set values with the same values." ); return ( 1 );
         case 2 :       Print ( "Common mistake. Stop all trading attempts until the circumstances are clarified." ); return ( 0 );
         case 3 :       Print ( "Wrong parameters passed to the trading function." ); return ( 1 );
         case 4 :       Print ( "The trading server is busy. Let's try again .." ); Sleep ( 3000 ); return ( 1 );
         case 5 :       Print ( "Old version of the client terminal." ); return ( 0 );
         case 6 :       Print ( "No connection to the trading server." ); return ( 1 );
         case 7 :       Print ( "Not enough rights." ); return ( 1 );
         case 8 :       Print ( "Too frequent requests." ); return ( 1 );
         case 9 :       Print ( "Invalid operation disrupting server operation." ); return ( 1 );
         case 64 :     Print ( "The account is blocked. It is necessary to stop all attempts at trading operations." ); return ( 0 );
         case 65 :     Print ( "Invalid account number." ); return ( 1 );
         case 128 :     Print ( "The transaction has expired." ); return ( 1 );
         case 129 :     Print ( "Wrong bid or ask price, possibly not normalized price." ); return ( 1 );
         case 130 :     Print ( "Stops that are too close or incorrectly calculated or abnormal prices in stops (or in the opening price of a pending order)." ); return ( 1 );
         case 131 :     Print ( "Wrong volume, error in granulation of volume." ); return ( 1 );
         case 132 :     Print ( "The market is closed." ); return ( 1 );
         case 133 :     Print ( "Trade is prohibited." ); return ( 0 );
         case 134 :     Print ( "Not enough money to complete the operation." ); return ( 0 );
         case 135 :     Print ( "The price has changed. We try again .." );RefreshRates(); return ( 1 );
         case 136 :     Print ( "No price. We are waiting for a new tick .." );
                     while (RefreshRates()== false ) // До нового тика
                     Sleep ( 1 );
                     return ( 1 );
         case 137 :     Print ( "The broker is busy. Let's try again .." ); Sleep ( 3000 ); return ( 1 );
         case 138 :     Print ( "The requested price is out of date, or bid and ask are confused." ); return ( 1 );
         case 139 :     Print ( "The order is blocked and is already being processed." ); return ( 1 );
         case 140 :     Print ( "Only purchase allowed. You cannot repeat the SELL operation." ); return ( 1 );
         case 141 :     Print ( "Too many requests." ); return ( 1 );
         case 142 :     Print ( "The order is queued." ); return ( 1 );
         case 143 :     Print ( "The order has been accepted by the dealer for execution." ); return ( 1 );
         case 144 :     Print ( "The order is canceled by the client upon manual confirmation of the transaction." ); return ( 1 );
         case 145 :     Print ( "Modification is prohibited, because the order is too close to the market and is blocked due to possible early execution." ); return ( 1 );
         case 146 :     Print ( "The trading subsystem is busy. Let's try again .." ); Sleep ( 500 ); return ( 1 );
         case 147 :     Print ( "Using the expiration date of the order is prohibited by the broker." ); return ( 1 );
         case 148 :     Print ( "The number of open and pending orders has reached the limit set by the broker." ); return ( 1 );
         case 149 :     Print ( "An attempt to open an opposite position to an existing one if hedging is prohibited." ); return ( 1 );
         case 4000 :   return ( 0 );
         case 4001 :   Print ( "Invalid function pointer." ); return ( 1 );
         case 4002 :   Print ( "Array index is out of range." ); return ( 1 );
         case 4003 :   Print ( "No memory for function stack." ); return ( 1 );
         case 4004 :   Print ( "Stack overflow after recursive call." ); return ( 1 );
         case 4005 :   Print ( "There is no memory on the stack for passing parameters." ); return ( 1 );
         case 4006 :   Print ( "There is no memory for the string parameter." ); return ( 1 );
         case 4007 :   Print ( "There is no memory for the time line." ); return ( 1 );
         case 4008 :   Print ( "Uninitialized string." ); return ( 1 );
         case 4009 :   Print ( "An uninitialized string in an array." ); return ( 1 );
         case 4010 :   Print ( "There is no memory for the string array." ); return ( 1 );
         case 4011 :   Print ( "Line is too long." ); return ( 1 );
         case 4012 :   Print ( "The remainder of division by zero." ); return ( 1 );
         case 4013 :   Print ( "Division by zero." ); return ( 1 );
         case 4014 :   Print ( "Unknown team." ); return ( 1 );
         case 4015 :   Print ( "Wrong transition." ); return ( 1 );
         case 4016 :   Print ( "Uninitialized array." ); return ( 1 );
         case 4017 :   Print ( "DLL calls are not allowed." ); return ( 1 );
         case 4018 :   Print ( "Unable to load library." ); return ( 1 );
         case 4019 :   Print ( "Unable to call function." ); return ( 1 );
         case 4020 :   Print ( "Calls to external library functions are not allowed." ); return ( 1 );
         case 4021 :   Print ( "There is not enough memory for the string returned from the function." ); return ( 1 );
         case 4022 :   Print ( "The system is busy." ); return ( 1 );
         case 4050 :   Print ( "Incorrect number of function parameters." ); return ( 1 );
         case 4051 :   Print ( "Invalid function parameter value." ); return ( 1 );
         case 4052 :   Print ( "Internal error of string function." ); return ( 1 );
         case 4053 :   Print ( "Array error." ); return ( 1 );
         case 4054 :   Print ( "Misuse of timeseries array." ); return ( 1 );
         case 4055 :   Print ( "Custom indicator error." ); return ( 1 );
         case 4056 :   Print ( "Arrays are incompatible." ); return ( 1 );
         case 4057 :   Print ( "Error processing global variables." ); return ( 1 );
         case 4058 :   Print ( "Global variable not detected." ); return ( 1 );
         case 4059 :   Print ( "Function not allowed in test mode." ); return ( 1 );
         case 4060 :   Print ( "Enter the HTTP address !!!." ); return ( 1 );
         case 4061 :   Print ( "Error sending mail." ); return ( 1 );
         case 4062 :   Print ( "A parameter of type string is expected." ); return ( 1 );
         case 4063 :   Print ( "A parameter of type integer is expected." ); return ( 1 );
         case 4064 :   Print ( "A parameter of type double is expected." ); return ( 1 );
         case 4065 :   Print ( "An array is expected as a parameter." ); return ( 1 );
         case 4066 :   Print ( "The requested historical data is in an update state." ); return ( 1 );
         case 4067 :   Print ( "An error occurred while performing a trading operation." ); return ( 1 );
         case 4099 :   Print ( "End of file." ); return ( 1 );
         case 4100 :   Print ( "An error occurred while working with the file." ); return ( 1 );
         case 4101 :   Print ( "Invalid file name." ); return ( 1 );
         case 4102 :   Print ( "Too many open files." ); return ( 1 );
         case 4103 :   Print ( "Unable to open file." ); return ( 1 );
         case 4104 :   Print ( "Incompatible file access mode." ); return ( 1 );
         case 4105 :   Print ( "No order has been selected." ); return ( 1 );
         case 4106 :   Print ( "Unknown character." ); return ( 1 );
         case 4107 :   Print ( "Incorrect price parameter for the trading function." ); return ( 1 );
         case 4108 :   Print ( "Invalid ticket number." ); return ( 1 );
         case 4109 :   Print ( "Trading is not permitted. You must enable the option Allow Expert Advisor to trade in the expert properties." ); return ( 1 );
         case 4110 :   Print ( "Long positions are not allowed. It is necessary to check the properties of the expert." ); return ( 1 );
         case 4111 :   Print ( "Short positions are not allowed. It is necessary to check the properties of the expert." ); return ( 1 );
         case 4200 :   Print ( "The object already exists." ); return ( 1 );
         case 4201 :   Print ( "An unknown property of the object was requested." ); return ( 1 );
         case 4202 :   Print ( "The object does not exist." ); return ( 1 );
         case 4203 :   Print ( "Unknown object type." ); return ( 1 );
         case 4204 :   Print ( "No object name." ); return ( 1 );
         case 4205 :   Print ( "Error coordinates of the object." ); return ( 1 );
         case 4206 :   Print ( "The specified subwindow was not found." ); return ( 1 );
         case 4207 :   Print ( "An error occurred while working with the object." ); return ( 1 );
         return ( 0 );
   }
   return ( 0 );
}
//+---------------------------------------------------------------

오류 없음

예, 그리고 그들은 어디에서 왔습니까? 최소 로트로 개설하는 경우에만 보증금을 허용하지 않습니다.

 
Renat Akhtyamov :

그것으로 10년

불평하지 않는다

적어도 백년은. 오류 코드에 대한 설명만 보고 어떻게 불평할 수 있습니까?

함수는 오류 코드를 설명할 수 있을 뿐만 아니라(여기서는 작업이 필요하지 않습니다. 도움말에서 복사) 핸들러에 대한 코드를 발행해야 합니다. 항상 0 또는 1의 코드를 받습니다.

그렇다면 함수 유형이 bool 이 아닌 int 인 이유는 무엇입니까?

그리고 당신은 핸들러가 없습니다. 그러나 처리는 함수가 절대적으로 모든 서버 응답에 대해 코드 1을 발행한 경우 어리석게도 return을 실행한다는 것입니다. 어디서, 어디서 - 아무도 모릅니다.

그래서 처리는 어디에 있습니까? 반환은 처리되지 않지만 서버에서 반환된 오류 코드를 처리해야 하는 문제에서 벗어나는 것입니다.

Документация по MQL5: Константы, перечисления и структуры / Коды ошибок и предупреждений
Документация по MQL5: Константы, перечисления и структуры / Коды ошибок и предупреждений
  • www.mql5.com
Константы, перечисления и структуры / Коды ошибок и предупреждений - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Andrey Kaunov :

코드를 수정하고 테스터에서 실행했습니다.

오류 없음

예, 그리고 그들은 어디에서 왔습니까? 최소 로트로 개설하는 경우에만 보증금을 허용하지 않습니다.

이러한 상황 에서 로그에 메시지를 출력하고 Expert Advisor의 작업을 계속하십시오.

 
Andrey Kaunov :

코드를 수정하고 테스터에서 실행했습니다.

오류 없음

예, 그리고 그들은 어디에서 왔습니까? 최소 로트로 개설하는 경우에만 보증금을 허용하지 않습니다.

나도 이걸로 망했어

최소 로트 0.1이 엄격하게 설정될 때까지

거래 작업 이 없는 이유를 오랫동안 이해할 수 없었습니다. tk. 검증인의 MarketInfo()는 최소값이 0.1이라고 대답하지 않았고, 그는 0(영) 또는 0.01이라고 대답했습니다. 이미 기억이 나지 않습니다.)

 

Artyom, 우리는 완전히 다른 것에 대해 이야기하고 있습니다. 코드는 투명합니다. 어디가 오류인지 알려주실 수 있나요? 그것이 일어날 장소와 상황을 정확히 보여주십시오.

보증금이 최소 랏으로 열리지 않는 경우 한 가지 상황만 봅니다. 그러나 이것은 이미 테스터의 의지입니다. 왜 최소한의 로트로 거래를 열 수없는 조건을 설정합니까?

그리고 그는 항상 NZDUSD에서만 이것을 합니까???

 
이 가장 간단한 코드에는 외부 매개변수가 전혀 없습니다. 모두가 알아차렸으면 합니다. 그는 어리석게도 정보 환경에서 제공하는 최소 랏으로 거래를 시작합니다.
 
Andrey Kaunov :
이 가장 간단한 코드에는 매개변수가 전혀 없습니다. 모두가 알아차렸으면 합니다. 그는 어리석게도 정보 환경에서 제공하는 최소 랏으로 거래를 시작합니다.

그리고 그들의 minlot이 0.1이라면?

나는 개인적으로 이것을 믿는다

;)

 

그건 그렇고, 티켓 # 0이 절대 발생하지 않는다고 확신합니까? :-)

 
Renat Akhtyamov :

그리고 그들의 minlot이 0.1이라면?

나는 개인적으로 이것을 믿는다

;)

Renat는 추측하지 않았습니다, 0.2))) 여기에서 제가 1분 로트를 열 가능성을 아직 확인하지 않은 테스트가 있습니다.

이전 게시물에서 모두 설명했습니다.


막심 쿠즈네초프 :

그건 그렇고, 티켓 # 0이 절대 발생하지 않는다고 확신합니까? :-)

나는 더 이상 아무것도 확신하지 못한다

 
Andrey Kaunov :

Renat는 추측하지 않았습니다. 0.2))) 여기에서 분 로트를 열 가능성을 아직 확인하지 않은 테스트가 있습니다.

이전 게시물에서 모두 설명했습니다.

잘 모든 것

테스터와 거래가 마진으로 시작한다면 물론 스프레드 비용을 고려하면 minlot에 대한 하드

유형: free margin*0.9 > lot*margin인 경우 거래