초보자의 질문 MQL5 MT5 MetaTrader 5 - 페이지 1342

 
Vladimir Karputov # :

OnDeinit에서 ObjectsDeleteAll - 접두사로 삭제해야 합니다(귀하의 경우 접두사는 "HLine")

그리고 어떤 줄에 "HLine"을 쓸까요?

 
Green handsome # :

그리고 어떤 줄에 "HLine"을 쓸까요?

정확히 무엇이 명확하지 않습니까?

거래, 자동 거래 시스템 및 거래 전략 테스트에 관한 포럼

초보자의 질문 MQL5 MT5 MetaTrader 5

블라디미르 카르푸토프 , 2021.09.10 15:53

OnDeinit에서는 ObjectsDeleteAll 을 수행해야 합니다 . 접두사로 삭제 ( 귀하의 경우 접두사는 "HLine" )

 int    ObjectsDeleteAll (
   long            chart_id,   // идентификатор графика
   const string      prefix,   // префикс имени объекта
   int        sub_window=- 1 ,   // индекс окна
   int       object_type=- 1      // тип объекта для удаления
   );


 
Vladimir Karputov # :

정확히 무엇이 명확하지 않습니까?


 int    ObjectsDeleteAll (
   long            chart_id,   // идентификатор графика
   const string       HLine,   // префикс имени объекта
   int        sub_window=- 1 ,   // индекс окна
   int       object_type=- 1      // тип объекта для удаления
   
   );

그래서 했는데 아직도 안 지워지네요.

 
void OnDeinit ( const int reason)
  {
     {
       ObjectsDeleteAll ( 0 ,prefix, 0 );
     }
//---
   //ChartRedraw();
  }

접두사는 그래픽 레이블을 만들기 위한 이름을 포함합니다.

접두사가 무엇을 의미하는지 아십니까?

 
Fast235 # :

접두사는 그래픽 레이블을 만들기 위한 이름을 포함합니다.

접두사가 무엇을 의미하는지 아십니까?

나는 MQL을 전혀 이해하지 못한다.... 나는 몇 줄을 고칠 줄 알았는데 그게 다야.

 
Green handsome # :

나는 MQL을 전혀 이해하지 못한다.... 나는 몇 줄을 고칠 줄 알았는데 그게 다야.

위의 코드는 도움이 될 것입니다. 그렇지 않으면 어떤 접두사 객체가 생성되는지 살펴보십시오.

 

왼쪽 상단 의 하위 창에 짧은 이름이 표시되지 않는 이유는 무엇입니까?


또한 하나의 지표가 차트에 로드되면 두 번째 복사본은 더 이상 작동하지 않습니다. OnInit() = 작동하지 않고 아무 것도 인쇄하지 않습니다. 그러나 "입력 매개변수"를 다른 것으로 변경하면 작동합니다.

 #property indicator_separate_window

#property indicator_plots 0

input int MASlow = 21 ; // Период медленной МА
input int MAFast = 8 ;   // Период быстрой МА

//+------------------------------------------------------------------+
string prog_name,short_name;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit ( void )
{
  prog_name= MQLInfoString ( MQL_PROGRAM_NAME );
  short_name= "=Set (" +( string )MASlow+ "/" +( string )MAFast+ ")" ;
   IndicatorSetString ( INDICATOR_SHORTNAME ,short_name);
   Print ( "INIT_SUCCEEDED" );
   return ( INIT_SUCCEEDED );
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
{
//---

//--- return value of prev_calculated for next call
   return (rates_total);
}

---

무엇이 잘못되었나요? mt4에서 이 코드가 작동합니다.

 
Vitaly Muzichenko # :

왼쪽 상단 의 하위 창에 짧은 이름이 표시되지 않는 이유는 무엇입니까?


또한 하나의 지표가 차트에 로드되면 두 번째 복사본은 더 이상 작동하지 않습니다. OnInit() = 작동하지 않고 아무 것도 인쇄하지 않습니다. 그러나 "입력 매개변수"를 다른 것으로 변경하면 작동합니다.

---

무엇이 잘못되었나요? mt4에서 이 코드가 작동합니다.

너무 짧게 잘려서 그럴까요? 디스플레이도 없고 버퍼도 없고... 왜 그런 표시기의 두 번째 복사본을 만들어 터미널이 자의적으로 작동하는지...

 
Vitaly Muzichenko # :

왼쪽 상단 의 하위 창에 짧은 이름이 표시되지 않는 이유는 무엇입니까?


또한 하나의 지표가 차트에 로드되면 두 번째 복사본은 더 이상 작동하지 않습니다. OnInit() = 작동하지 않고 아무 것도 인쇄하지 않습니다. 그러나 "입력 매개변수"를 다른 것으로 변경하면 작동합니다.

---

무엇이 잘못되었나요? mt4에서 이 코드가 작동합니다.

뭔가가 빠졌습니다 - 아마도 어떤 종류의 속성일 것입니다. 나는 또한 이것을 만났지만 지표를 스케치했습니다. 모든 것이 정상입니다.

 #property copyright "Copyright 2021, IgorM"
#property link        " https://www.mql5.com/ru/users/igorm "
#property version    "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots    1
//--- plot Label1
#property indicator_label1    "Label1"
#property indicator_type1    DRAW_LINE
#property indicator_color1    clrRed
#property indicator_style1    STYLE_SOLID
#property indicator_width1    2
//--- indicator buffers
double          Label1Buffer[];
input int MASlow = 21 ; // Период медленной МА
input int MAFast = 8 ;   // Период быстрой МА
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
{
//--- indicator buffers mapping
   string short_name = MQLInfoString ( MQL_PROGRAM_NAME ) + "=Set (" + ( string )MASlow + "/" + ( string )MAFast + ")" ;
   IndicatorSetString ( INDICATOR_SHORTNAME , short_name);
   SetIndexBuffer ( 0 , Label1Buffer, INDICATOR_DATA );
//---
   return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
{
   for ( int i = prev_calculated == 0 ? 0 : prev_calculated - 1 ; i < rates_total; i++)
   {
      Label1Buffer[i] = close[i];
   }
   return (rates_total);
}
//+------------------------------------------------------------------+

표시기 이름이 하위 창에서 쓰기를 중지할 때 검색하기 위해 주석 처리할 수 있습니다. 하지만 너무 게으릅니다.

 
Igor Makanu # :

뭔가가 빠졌습니다 - 아마도 어떤 종류의 속성일 것입니다. 나는 또한 이것을 만났지만 지표를 스케치했습니다. 모든 것이 정상입니다.

표시기 이름이 하위 창에서 쓰기를 중지할 때 검색하기 위해 주석 처리할 수 있습니다. 하지만 너무 게으릅니다.

데이터가 표시되는데, 어디서 OnInit () 함수가 작동하지 않는다면? 차트에 복사본을 던지면 OnInit()이 우발적으로 작동할 수 있지만 다른 복사본이 있으면 인쇄가 없더라도 그뿐입니다. 그러나 입력 매개 변수를 변경하면 작동합니다.

 #property copyright "Copyright 2021, IgorM"
#property link        " https://www.mql5.com/ru/users/igorm "
#property version    "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots    1
//--- plot Label1
#property indicator_label1    "Label1"
#property indicator_type1    DRAW_LINE
#property indicator_color1    clrRed
#property indicator_style1    STYLE_SOLID
#property indicator_width1    2


input int MASlow = 21 ; // Период медленной МА
input int MAFast = 8 ;   // Период быстрой МА

//+------------------------------------------------------------------+
int wndNum;
string short_name;
double Label1Buffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
{
  short_name= "Set (" +( string )MASlow+ "/" +( string )MAFast+ ")" ;
   IndicatorSetString ( INDICATOR_SHORTNAME ,short_name);
  wndNum= ChartWindowFind ();
   Print ( "INIT SUCCEEDED: " +( string )wndNum);
   SetIndexBuffer ( 0 , Label1Buffer, INDICATOR_DATA );
//---
   return ( INIT_SUCCEEDED );
}

//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
{
   for ( int i = prev_calculated == 0 ? 0 : prev_calculated - 1 ; i < rates_total; i++)
   {
      Label1Buffer[i] = close[i];
   }
   return (rates_total);
}

---

출력은 무엇이며 OnInit 가 작동하지 않는 이유는 무엇입니까?

사유: