초보자의 질문 MQL4 MT4 MetaTrader 4 - 페이지 196

 
Vitaly Muzichenko :

이것은 레이아웃이며 4와 5의 차이가 없습니다.

핸들은 모든 단계가 아니라 OnInit()에서 한 번만 생성되어야 합니다. 이거 아직도 모르세요?

 
삭제됨, 해결해야 함
 
Vitaly Muzichenko :

그래서?

그래서 여전히 각 틱에 핸들을 만듭니다 . Styler를 사용하면 로직 구축 오류가 즉시 표시됩니다.

 //+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double MA( string symb, ENUM_TIMEFRAMES tf, int period, int ma_shift,
           ENUM_MA_METHOD method, ENUM_APPLIED_PRICE price, int index)
  {
#ifdef __MQL4__
   return ( iMA (symb,tf,period,ma_shift,method,price,index));
#else
   double buf[ 1 ];
   static int hMA=- 1 ;
   int handle= iMA (symb,tf,period,ma_shift,method,price);
   if (handle<hMA)
     {
       PrintFormat ( "Failed to create handle MA %s/%s, Error: %d" ,symb,sTF(tf), GetLastError ());
       return ( WRONG_VALUE );
     }
   else
     {
       if ( CopyBuffer (handle, 0 ,index, 1 ,buf)< 0 )
        {
         PrintFormat ( "Failed to copy data from the indicator MA %s/%s, Error: %d" ,symb,sTF(tf), GetLastError ());
         return ( WRONG_VALUE );
        }
     }
   hMA=handle;
   return (buf[ 0 ]);
#endif
   }
 
Vladimir Karputov :

그래서 여전히 모든 틱에 핸들을 생성합니다 . Styler를 사용하면 로직 구축 오류가 즉시 표시됩니다.

그렇게

 double MA( string symb, ENUM_TIMEFRAMES tf, int period, int ma_shift,
                                       ENUM_MA_METHOD method, ENUM_APPLIED_PRICE price, int index) {
 #ifdef __MQL4__
   return ( iMA (symb,tf,period,ma_shift,method,price,index));
 #else
   double buf[ 1 ];
   static int handle=- 1 ;
   if (handle< 0 ) {
    handle= iMA (symb,tf,period,ma_shift,method,price);
   }
   if (handle< 0 ) {
     PrintFormat ( "Failed to create handle MA %s/%s, Error: %d" ,symb,sTF(tf), GetLastError ());
     return ( WRONG_VALUE );
   } else {
     if ( CopyBuffer (handle, 0 ,index, 1 ,buf)< 0 ) {
     PrintFormat ( "Failed to copy data from the indicator MA %s/%s, Error: %d" ,symb,sTF(tf), GetLastError ());
     return ( WRONG_VALUE );
    }
   }
   return (buf[ 0 ]);
 #endif
 }
또한 나머지 피크 값 검색 코드를 크로스 플랫폼으로 작성합니다.
 
Vitaly Muzichenko :

그렇게

또한 나머지 피크 값 검색 코드를 크로스 플랫폼으로 작성합니다.

네 지금 요

 //+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double MA( string symb, ENUM_TIMEFRAMES tf, int period, int ma_shift,
           ENUM_MA_METHOD method, ENUM_APPLIED_PRICE price, int index)
  {
#ifdef __MQL4__
   return ( iMA (symb,tf,period,ma_shift,method,price,index));
#else
   double buf[ 1 ];
   static int handle=- 1 ;
   if (handle< 0 )
     {
       handle= iMA (symb,tf,period,ma_shift,method,price);
     }
   if (handle< 0 )
     {
       PrintFormat ( "Failed to create handle MA %s/%s, Error: %d" ,symb,sTF(tf), GetLastError ());
       return ( WRONG_VALUE );
     }
   else
     {
       if ( CopyBuffer (handle, 0 ,index, 1 ,buf)< 0 )
        {
         PrintFormat ( "Failed to copy data from the indicator MA %s/%s, Error: %d" ,symb,sTF(tf), GetLastError ());
         return ( WRONG_VALUE );
        }
     }
   return (buf[ 0 ]);
#endif
   }

분명히 더 좋습니다. 그러나 이 블록은 제자리에 있지 않습니다 . 핸들이 생성된 직후에 배치되어야 합니다.

 
Vladimir Karputov :

네 지금 요

분명히 더 좋습니다. 그러나 이 블록은 제자리에 있지 않습니다 . 핸들이 생성된 직후에 배치되어야 합니다.

최적의 경우 아마도 이와 같이 생성 오류를 한 번 인쇄하지만 다음 경우에 대한 검사는 더 적습니다(...)

 double MA( string symb, ENUM_TIMEFRAMES tf, int period, int ma_shift,
                                       ENUM_MA_METHOD method, ENUM_APPLIED_PRICE price, int index) {
 #ifdef __MQL4__
   return ( iMA (symb,tf,period,ma_shift,method,price,index));
 #else
   double buf[ 1 ];
   static int handle=- 1 ;
   if (handle< 0 ) {
    handle= iMA (symb,tf,period,ma_shift,method,price);
     PrintFormat ( "Failed to create handle MA %s/%s, Error: %d" ,symb,sTF(tf), GetLastError ());
     return ( WRONG_VALUE );
   } else {
     if ( CopyBuffer (handle, 0 ,index, 1 ,buf)< 0 ) {
     PrintFormat ( "Failed to copy data from the indicator MA %s/%s, Error: %d" ,symb,sTF(tf), GetLastError ());
     return ( WRONG_VALUE );
    }
   }
   return (buf[ 0 ]);
 #endif
 }
 
Vitaly Muzichenko :

최적의 경우 아마도 이와 같이 생성 오류를 한 번 인쇄하지만 다음 경우에 대한 검사는 더 적습니다(...)

나는 당신의 죽에서 아무것도 볼 수 없습니다 - 모든 것이 합쳐집니다.

스타일러 를 사용하세요.
 
Vladimir Karputov :

나는 당신의 죽에서 아무것도 볼 수 없습니다 - 모든 것이 합쳐집니다.

스타일러 를 사용하세요.

그렇다면 스타일리스트에서 내 스타일을 본 것은 아니지만 오, 몇 개나

파일:
cc.PNG  100 kb
 

불행히도 내 표시기는 MQL4를 기반으로 하며 이 기능은 그 중 일부에 불과합니다.

따라서 MQL5를 거기에 구현하는 것은 그다지 효율적이지 않지만 완전히 다시 작성하는 것은 길고 문제가 많습니다.

 
GlaVredFX :

불행히도 내 표시기는 MQL4를 기반으로 하며 이 기능은 그 중 일부에 불과합니다.

따라서 MQL5를 거기에 구현하는 것은 그다지 효율적이지 않지만 완전히 다시 작성하는 것은 길고 문제가 많습니다.

표시기는 평균 30분 만에 MQL5로 다시 작성됩니다. 커피 한잔과 함께.