OnBookEvent에 대한 구독이 때때로 중단됩니다. 그런 일이 있습니까? - 페이지 9

 

하나의 목발 솔루션이 있습니다.

TERMINAL 의 전역 변수를 통해 자신의 카운터를 만듭니다.

동일한 기호의 두 창이 고유한 이름을 만들 수 있도록 고유한 이름을 생각하면 됩니다.

터미널 전역 변수.

추가됨

두 개의 기호 창을 열지 않으려면 터미널의 전역 변수 이름으로

당신은 마법을 사용할 수 있습니다

 //+------------------------------------------------------------------+
//|                                                    AutoMagic.mqh |
//|                                      Copyright 2017 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//version   "1.34
ulong symb_magic;
//-------------------------------------------------------------------+
// Split string function                                             |
//+------------------------------------------------------------------+
string SplitString( const string a_str, ulong &a_month, ulong &a_year)
  {
   int str_size= StringLen (a_str);
   int str_tire= StringFind (a_str, "-" );
   int str_tochka= StringFind (a_str, "." , str_tire);
   if ((str_tire> 0 ) && (str_tochka> 0 ) &&(str_size > 0 ))
     {
      a_month= ulong ( StringToInteger ( StringSubstr (a_str,str_tire+ 1 ,str_tochka-str_tire- 1 )));
      a_year = ulong ( StringToInteger ( StringSubstr (a_str,str_tochka+ 1 ,str_size-str_tochka- 1 )));
       if ((a_month > 0 ) && (a_year > 0 )) return ( StringSubstr (a_str, 0 , str_tire));
     }
   return ( "" );
  }
//-------------------------------------------------------------------+
// Get Magic function                                                |
//+------------------------------------------------------------------+
ulong GetMagic( const string a_symbol)
  {
   if ( StringLen (a_symbol)> 10 )
   {
     Print ( __FUNCTION__ , "Invalid magic string!" );
     return ( 0 );
   }
   ulong month = 0 ;
   ulong year = 0 ;
   string new_str=SplitString(a_symbol,month,year);
   if ( StringLen (new_str)> 0 )
     {
       uchar char_array[];
       int result= StringToCharArray (new_str,char_array, 0 , WHOLE_ARRAY , CP_ACP );
       if (result> 0 )
        {
         ulong value;
         ulong cur_magic = 0 ;
         for ( int i = 0 ; i < result - 1 ; i++)
           {
            value= ulong (char_array[i]);
            value<<=( 40 -(i* 8 ));
            cur_magic+=value;
           }
         month<<= 8 ;
         cur_magic += month;
         cur_magic += year;
         if (a_symbol == Symbol ())
         {
           symb_magic = cur_magic <<= 16 ;
           return (symb_magic);
         }
         else return (cur_magic <<= 16 );
        }
     }
   return ( 0 );
  }
//-------------------------------------------------------------------+
// Is my magic function                                              |
//+------------------------------------------------------------------+
bool IsMyMagic( const ulong m_magic)
  {
   ulong in_magic=m_magic;
   ulong stored_magic=symb_magic;
   in_magic>>= 16 ;
   stored_magic>>= 16 ;
   if (stored_magic == in_magic) return ( true );
   return ( false );
  }
//+------------------------------------------------------------------+

또는 기호 이름만

예: "Si-9.18_bookcount"

이것이 내가 보류 중인 주문에 대한 담보(GO) 자금을 계산하는 방법입니다.

 
prostotrader :
동일한 기호의 두 창이 자체 전역 터미널 변수를 생성하도록 고유한 이름을 생각하면 됩니다.
https://www.mql5.com/en/forum/267154/page8#comment_8171650 이보다 더 좋은 이름을 생각해내는 것은 거의 불가능합니다.
Подписка на OnBookEvent иногда отваливается - есть такое?
Подписка на OnBookEvent иногда отваливается - есть такое?
  • 2018.07.24
  • www.mql5.com
После того как поплотнее занялся стаканом и повесил на чарты несколько экспертов и индикаторов, подписанных на OnBookEvent, обнаружил, что некоторы...
 
A100 :
https://www.mql5.com/en/forum/267154/page8#comment_8171650 이보다 더 좋은 이름을 생각해내는 것은 거의 불가능합니다.

훌륭하지만 이름은 중요하지 않습니다. 중요한 것은 하나 이상의 창이 있으면 고유합니다.

추가됨

내가 어딘가에 틀렸다면 나를 수정하십시오.

 //+------------------------------------------------------------------+
//|                                                    BookCount.mqh |
//|                                      Copyright 2018 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018 prostotrader"
#property link        "https://www.mql5.com"
//
//+------------------------------------------------------------------+
//| Create book count function                                       |
//+------------------------------------------------------------------+
string CreateBookCount( int &cnt)
{
   string book_cnt_name = IntegerToString ( ChartID ());
   if ( GlobalVariableCheck (book_cnt_name) == true )
  {
     double curr_value;
     if ( GlobalVariableGet (book_cnt_name, curr_value) == true )
    {
      cnt = int (curr_value);
       return (book_cnt_name);
    }  
  }
   else
  {
    cnt = 0;
     if ( ulong ( GlobalVariableSet (book_cnt_name, double (cnt))) > 0 )
    {
       return (book_cnt_name);
    }
  }
   return ( "" ); 
}
//+------------------------------------------------------------------+
//| Delete book count function                                       |
//+------------------------------------------------------------------+
bool DeleteBookCount( const string cnt_name)
{
   if ( GlobalVariableCheck (cnt_name) == true )
  {
     return ( GlobalVariableDel (cnt_name));
  }
   return ( false );
}
//+------------------------------------------------------------------+
//| Book count update function                                       |
//+------------------------------------------------------------------+
bool BookCountUpdate( const string cnt_name, int &value, const bool is_update)
{
   if ( GlobalVariableCheck (cnt_name) == true )
  {
     double curr_value;
     double new_value;
     if ( GlobalVariableGet (cnt_name, curr_value) == true )
    {
       if (is_update == true )
      {
        new_value = curr_value + 1 ;
      }
       else
      {
        new_value = curr_value - 1 ;
      }
       int i = 0 ;  
       do
      {
        i++;
         if ( GlobalVariableSetOnCondition (cnt_name, new_value, curr_value) == true )
        {
          value = int (new_value);
           return ( true );
        }  
     }  
     while (i < 100 );
    }
  }
   return ( false );
}
 
prostotrader :
내가 어딘가에 틀렸다면 나를 수정하십시오.

이름의 고유성은 기호의 이름과 직접적인 관련이 있으며 보다 일반적인 경우를 의미했습니다.

 IntegerToString ( ChartID ()) + ":" + symbol

저것들. 귀하의 경우와 관련하여(차트의 모든 MQL 프로그램이 현재 기호에서만 작동하는 경우)

 IntegerToString ( ChartID ()) + ":" + Symbol ()

대신에

 IntegerToString ( ChartID ())
그건 실수가 아니야... 그냥 규율이야
 

얘들아!

우리는 결코 MT-5를 "패배"하지 않을 것입니다!

지표 1

 //+------------------------------------------------------------------+
//|                                                   Test_ind_1.mq5 |
//|                                      Copyright 2018 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018 prostotrader"
#property link        "https://www.mql5.com"
#property version    "1.00"
#include   "..\Include\BookCount.mqh"
#define on_call - 111
#property indicator_separate_window
string b_cnt_name;
int book_count;
bool is_book;
double Buff[];
int event_cnt = 0 ;
#property indicator_buffers 1
#property indicator_plots    1
//--- plot Label1
#property indicator_label1    "Test_1"
#property indicator_type1    DRAW_LINE
#property indicator_color1    clrAqua
#property indicator_style1    STYLE_SOLID
#property indicator_width1    1
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
    b_cnt_name = CreateBookCount(book_count);
     if (b_cnt_name == "" ) return ( INIT_FAILED );
   //--- Set buffers 
   IndicatorSetInteger ( INDICATOR_DIGITS , 0 );
   IndicatorSetString ( INDICATOR_SHORTNAME , "Test_ind_1" );
//---Set buffers
   SetIndexBuffer ( 0 ,Buff, INDICATOR_DATA );
   PlotIndexSetDouble ( 0 , PLOT_EMPTY_VALUE , EMPTY_VALUE );
   ArraySetAsSeries (Buff, true ); 
   is_book = MarketBookAdd ( Symbol ());
   if (is_book == true )
    { 
       Print ( __FUNCTION__ , ": Подписка на стакан добавлена. Символ " , Symbol ());
       if (BookCountUpdate(b_cnt_name, book_count, true ) == true )
      {
         Print ( __FUNCTION__ , ": Счётчик подписок обновлён. Символ " , Symbol ());
             Print ( __FUNCTION__ , ": Book count: " , book_count);
      }
    }
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
     Print ( __FUNCTION__ , ": Book count: " , book_count);
     if (book_count > 1 )
    {
       if (BookCountUpdate(b_cnt_name, book_count, false ) == true )
      {
         Print ( __FUNCTION__ , ": Счётчик подписок обновлён. Символ " , Symbol ());
         Print ( __FUNCTION__ , ": Book count: " , book_count);
      }
    }
     else
    { 
       Print ( __FUNCTION__ , ": Book count: " , book_count);
       MarketBookRelease ( Symbol ());
       Print ( __FUNCTION__ , ": Подписка на стакан удалена. Символ " , Symbol ());
      DeleteBookCount(b_cnt_name);
       Print ( __FUNCTION__ , ": Счётчик подписок удален. Символ " , Symbol ());
    }
  }  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const int begin,
                 const double &price[])
  {
     if (prev_calculated == 0 )
    {
       ArrayInitialize (Buff, EMPTY_VALUE );
    }
   Buff[ 0 ] = 2 ;
//--- return value of prev_calculated for next call
   event_cnt = rates_total;
   return (rates_total);
  }
//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent ( const string &symbol)
  {
   if (symbol == Symbol ())
   {
     // Print(__FUNCTION__, ": Подписка работает. Символ ", Symbol());
       double price[];
       OnCalculate (event_cnt,event_cnt,on_call,price);
   }
   
  }  
//+------------------------------------------------------------------+

지표 2

 //+------------------------------------------------------------------+
//|                                                   Test_ind_2.mq5 |
//|                                      Copyright 2018 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018 prostotrader"
#property link        "https://www.mql5.com"
#property version    "1.00"
#include   "..\Include\BookCount.mqh"
#define on_call - 111
#property indicator_separate_window
string b_cnt_name;
int book_count;
bool is_book;
double Buff[];
int event_cnt = 0 ;
#property indicator_buffers 1
#property indicator_plots    1
//--- plot Label1
#property indicator_label1    "Test_1"
#property indicator_type1    DRAW_LINE
#property indicator_color1    clrLime
#property indicator_style1    STYLE_SOLID
#property indicator_width1    1
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
    b_cnt_name = CreateBookCount(book_count);
     if (b_cnt_name == "" ) return ( INIT_FAILED );
   //--- Set buffers 
   IndicatorSetInteger ( INDICATOR_DIGITS , 0 );
   IndicatorSetString ( INDICATOR_SHORTNAME , "Test_ind_2" );
//---Set buffers
   SetIndexBuffer ( 0 ,Buff, INDICATOR_DATA );
   PlotIndexSetDouble ( 0 , PLOT_EMPTY_VALUE , EMPTY_VALUE );
   ArraySetAsSeries (Buff, true ); 
   is_book = MarketBookAdd ( Symbol ());
   if (is_book == true )
    { 
       Print ( __FUNCTION__ , ": Подписка 2 на стакан добавлена. Символ " , Symbol ());
       if (BookCountUpdate(b_cnt_name, book_count, true ) == true )
      {
         Print ( __FUNCTION__ , ": Счётчик подписок обновлён. Символ " , Symbol ());
         Print ( __FUNCTION__ , ": Book count: " , book_count);
      }
    }
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
     Print ( __FUNCTION__ , ": Book count: " , book_count);
     if (book_count > 1 )
    {
       if (BookCountUpdate(b_cnt_name, book_count, false ) == true )
      {
         Print ( __FUNCTION__ , ": 2 Счётчик подписок обновлён. Символ " , Symbol ());
         Print ( __FUNCTION__ , ": 2 Book count: " , book_count);
      }
    }
     else
    { 
       MarketBookRelease ( Symbol ());
       Print ( __FUNCTION__ , ": Подписка 2 на стакан удалена. Символ " , Symbol ());
      DeleteBookCount(b_cnt_name);
       Print ( __FUNCTION__ , ": Счётчик подписок удален. Символ " , Symbol ());
       Print ( __FUNCTION__ , ": Book count: " , book_count);
    }
  }  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const int begin,
                 const double &price[])
  {
     if (prev_calculated == 0 )
    {
       ArrayInitialize (Buff, EMPTY_VALUE );
    }
   Buff[ 0 ] = 2 ;
//--- return value of prev_calculated for next call
   event_cnt = rates_total;
   return (rates_total);
  }
//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent ( const string &symbol)
  {
   if (symbol == Symbol ())
   {
     // Print(__FUNCTION__, ": Подписка 2 работает. Символ ", Symbol());
       double price[];
       OnCalculate (event_cnt,event_cnt,on_call,price);
   }
   
  }  
//+------------------------------------------------------------------+

전역 변수


결과 1

 2018.07 . 25 19 : 34 : 43.733 Test_ind_1 (Si- 9.18 ,M1) OnInit : Подписка на стакан добавлена. Символ Si- 9.18
2018.07 . 25 19 : 34 : 43.733 Test_ind_1 (Si- 9.18 ,M1) OnInit : Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 19 : 34 : 43.733 Test_ind_1 (Si- 9.18 ,M1) OnInit : Book count: 1
2018.07 . 25 19 : 34 : 49.980 Test_ind_2 (Si- 9.18 ,M1) OnInit : Подписка 2 на стакан добавлена. Символ Si- 9.18
2018.07 . 25 19 : 34 : 49.980 Test_ind_2 (Si- 9.18 ,M1) OnInit : Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 19 : 34 : 49.980 Test_ind_2 (Si- 9.18 ,M1) OnInit : Book count: 2
2018.07 . 25 19 : 35 : 06.149 Test_ind_2 (Si- 9.18 ,M1) OnDeinit : Book count: 2
2018.07 . 25 19 : 35 : 06.149 Test_ind_2 (Si- 9.18 ,M1) OnDeinit : 2 Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 19 : 35 : 06.149 Test_ind_2 (Si- 9.18 ,M1) OnDeinit : 2 Book count: 1
2018.07 . 25 19 : 35 : 17.408 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Book count: 1
2018.07 . 25 19 : 35 : 17.408 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Book count: 1
2018.07 . 25 19 : 35 : 17.408 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Подписка на стакан удалена. Символ Si- 9.18
2018.07 . 25 19 : 35 : 17.408 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Счётчик подписок удален. Символ Si- 9.18

결과 2

 2018.07 . 25 19 : 42 : 34.884 Test_ind_1 (Si- 9.18 ,M1) OnInit : Подписка на стакан добавлена. Символ Si- 9.18
2018.07 . 25 19 : 42 : 34.884 Test_ind_1 (Si- 9.18 ,M1) OnInit : Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 19 : 42 : 34.884 Test_ind_1 (Si- 9.18 ,M1) OnInit : Book count: 1
2018.07 . 25 19 : 42 : 41.019 Test_ind_2 (Si- 9.18 ,M1) OnInit : Подписка 2 на стакан добавлена. Символ Si- 9.18
2018.07 . 25 19 : 42 : 41.019 Test_ind_2 (Si- 9.18 ,M1) OnInit : Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 19 : 42 : 41.019 Test_ind_2 (Si- 9.18 ,M1) OnInit : Book count: 2
2018.07 . 25 19 : 42 : 46.310 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Book count: 1
2018.07 . 25 19 : 42 : 46.310 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Book count: 1
2018.07 . 25 19 : 42 : 46.311 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Подписка на стакан удалена. Символ Si- 9.18
2018.07 . 25 19 : 42 : 46.311 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Счётчик подписок удален. Символ Si- 9.18
2018.07 . 25 19 : 42 : 57.445 Test_ind_2 (Si- 9.18 ,M1) OnDeinit : Book count: 2

지표 1개를 넣은 다음 두 번째 지표를 넣으면

첫 번째 표시기를 제거할 때 - 완전한 쓰레기(결과 2), 그러나

첫 번째 지표를 먼저 넣고 두 번째 지표를 넣은 다음

두 번째를 삭제한 다음 첫 번째를 삭제하면 모든 것이 정상입니다(결과 1)!


추가됨

2개의 표시기가 추가되면 표시기를 제거할 때

먼저 배치되었다

void OnDeinit(const int reason)은 차트에 표시되는 횟수만큼 호출됩니다!

 
prostotrader :

얘들아!

우리는 결코 MT-5를 "패배"하지 않을 것입니다!

일반적으로 전역 변수 로 작업할 때 함정이 있습니다 ... 코드에 약간의 오류가 생겼을 수도 있습니다 ... 지금 모바일을 사용 중입니다. 누군가 컴퓨터에서 확인할 수 있습니다. 도움이 될 것입니다.

 

아아아!! 각 지표에는 지표를 삭제하기 전에 업데이트해야 하는 자체 변수가 있는 것 같습니다! :)

내가 고칠게

 

네, 제 실수입니다. 모든 것이 올바르게 작동했습니다.

 2018.07 . 25 20 : 25 : 20.924 Test_ind_1 (Si- 9.18 ,M1) OnInit : Indicator1 - Подписка на стакан добавлена. Символ Si- 9.18
2018.07 . 25 20 : 25 : 20.924 Test_ind_1 (Si- 9.18 ,M1) OnInit : Indicator1 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 25 : 20.924 Test_ind_1 (Si- 9.18 ,M1) OnInit : Indicator1 - Book count: 1
2018.07 . 25 20 : 25 : 25.325 Test_ind_2 (Si- 9.18 ,M1) OnInit : Indicator 2 - Подписка на стакан добавлена. Символ Si- 9.18
2018.07 . 25 20 : 25 : 25.325 Test_ind_2 (Si- 9.18 ,M1) OnInit : Indicator 2 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 25 : 25.325 Test_ind_2 (Si- 9.18 ,M1) OnInit : Indicator 2 - Book count: 2
2018.07 . 25 20 : 25 : 29.813 Test_ind_3 (Si- 9.18 ,M1) OnInit : Indicator 3 - Подписка на стакан добавлена. Символ Si- 9.18
2018.07 . 25 20 : 25 : 29.813 Test_ind_3 (Si- 9.18 ,M1) OnInit : Indicator 3 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 25 : 29.813 Test_ind_3 (Si- 9.18 ,M1) OnInit : Indicator 3 - Book count: 3
2018.07 . 25 20 : 25 : 38.919 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Indicator1 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 25 : 38.919 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Indicator1 - Book count: 2
2018.07 . 25 20 : 25 : 53.097 Test_ind_3 (Si- 9.18 ,M1) OnDeinit : Indicator 3 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 25 : 53.097 Test_ind_3 (Si- 9.18 ,M1) OnDeinit : Indicator 3 - Book count: 1
2018.07 . 25 20 : 25 : 58.296 Test_ind_2 (Si- 9.18 ,M1) OnDeinit : Indicator 2 - Подписка на стакан удалена. Символ Si- 9.18
2018.07 . 25 20 : 25 : 58.296 Test_ind_2 (Si- 9.18 ,M1) OnDeinit : Indicator 2 - Счётчик подписок удален. Символ Si- 9.18

첨부 파일

 //+------------------------------------------------------------------+
//|                                                    BookCount.mqh |
//|                                      Copyright 2018 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018 prostotrader"
#property link        "https://www.mql5.com"
//
//+------------------------------------------------------------------+
//| Ctrate book count function                                       |
//+------------------------------------------------------------------+
string CreateBookCount( int &cnt)                       //return book count name & count value
  {
   string book_cnt_name= IntegerToString ( ChartID ());
   if ( GlobalVariableCheck (book_cnt_name)== true )
     {
       double curr_value;
       if ( GlobalVariableGet (book_cnt_name,curr_value)== true )
        {
         cnt= int (curr_value);
         return (book_cnt_name);
        }
     }
   else
     {
      cnt= 0 ;
       if ( ulong ( GlobalVariableSet (book_cnt_name, double (cnt)))> 0 )
        {
         return (book_cnt_name);
        }
     }
   return ( "" );
  }
//+------------------------------------------------------------------+
//| Delete book count function                                       |
//+------------------------------------------------------------------+
bool DeleteBookCount( const string cnt_name) //delete g;obal variable book count
  {
   if ( GlobalVariableCheck (cnt_name)== true )
     {
       return ( GlobalVariableDel (cnt_name));
     }
   return ( false );
  }
//+------------------------------------------------------------------+
//| Book count update function                                       |
//+------------------------------------------------------------------+
bool BookCountUpdate( const string cnt_name, int &value, const bool is_update) //Update book count global variable
  {
   if ( GlobalVariableCheck (cnt_name)== true )
     {
       double curr_value;
       double new_value;
       if ( GlobalVariableGet (cnt_name,curr_value)== true )
        {
         if (is_update== true )
           {
            new_value=curr_value+ 1 ;
           }
         else
           {
            new_value=curr_value- 1 ;
           }
         int i= 0 ;
         do
           {
            i++;
             if ( GlobalVariableSetOnCondition (cnt_name,new_value,curr_value)== true )
              {
               value= int (new_value);
               return ( true );
              }
           }
         while (i< 100 );
        }
     }
   return ( false );
  }
//+------------------------------------------------------------------+
//| Get book count function                                       |
//+------------------------------------------------------------------+
bool GetBookCount( const string cnt_name, int &cnt) 
  {
   if ( GlobalVariableCheck (cnt_name)== true )
     {
       double curr_value;
       if ( GlobalVariableGet (cnt_name,curr_value)== true )
        {
         cnt= int (curr_value);
         return ( true );
        }
     }
   return ( false );
  }
//+------------------------------------------------------------------+

지시자

 //+------------------------------------------------------------------+
//|                                                   Test_ind_1.mq5 |
//|                                      Copyright 2018 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018 prostotrader"
#property link        "https://www.mql5.com"
#property version    "1.00"
#include   "..\Include\BookCount.mqh"
#define on_call - 111
#property indicator_separate_window
string b_cnt_name;
int book_count;
bool is_book;
double Buff[];
int event_cnt = 0 ;
#property indicator_buffers 1
#property indicator_plots    1
//--- plot Label1
#property indicator_label1    "Test_1"
#property indicator_type1    DRAW_LINE
#property indicator_color1    clrAqua
#property indicator_style1    STYLE_SOLID
#property indicator_width1    1
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
    b_cnt_name = CreateBookCount(book_count);
     if (b_cnt_name == "" ) return ( INIT_FAILED );
   //--- Set buffers 
   IndicatorSetInteger ( INDICATOR_DIGITS , 0 );
   IndicatorSetString ( INDICATOR_SHORTNAME , "Test_ind_1" );
//---Set buffers
   SetIndexBuffer ( 0 ,Buff, INDICATOR_DATA );
   PlotIndexSetDouble ( 0 , PLOT_EMPTY_VALUE , EMPTY_VALUE );
   ArraySetAsSeries (Buff, true ); 
   is_book = MarketBookAdd ( Symbol ());
   if (is_book == true )
    { 
       Print ( __FUNCTION__ , ": Indicator1 - Подписка на стакан добавлена. Символ " , Symbol ());
       if (BookCountUpdate(b_cnt_name, book_count, true ) == true )
      {
         Print ( __FUNCTION__ , ": Indicator1 - Счётчик подписок обновлён. Символ " , Symbol ());
             Print ( __FUNCTION__ , ": Indicator1 - Book count: " , book_count);
      }
    }
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
     if (GetBookCount(b_cnt_name, book_count) == true )
    {
       if (book_count > 1 )
      {
         if (BookCountUpdate(b_cnt_name, book_count, false ) == true )
        {
           Print ( __FUNCTION__ , ": Indicator1 - Счётчик подписок обновлён. Символ " , Symbol ());
           Print ( __FUNCTION__ , ": Indicator1 - Book count: " , book_count);
        }
      }
       else
      { 
         MarketBookRelease ( Symbol ());
         Print ( __FUNCTION__ , ": Indicator1 - Подписка на стакан удалена. Символ " , Symbol ());
         if (DeleteBookCount(b_cnt_name) == true )
        {
           Print ( __FUNCTION__ , ": Indicator1 - Счётчик подписок удален. Символ " , Symbol ());
        }  
      }
    }
  }  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const int begin,
                 const double &price[])
  {
     if (prev_calculated == 0 )
    {
       ArrayInitialize (Buff, EMPTY_VALUE );
    }
   Buff[ 0 ] = 2 ;
//--- return value of prev_calculated for next call
   event_cnt = rates_total;
   return (rates_total);
  }
//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent ( const string &symbol)
  {
   if (symbol == Symbol ())
   {
     // Print(__FUNCTION__, ": Подписка работает. Символ ", Symbol());
       double price[];
       OnCalculate (event_cnt,event_cnt,on_call,price);
   }
   
  }  
//+------------------------------------------------------------------+


모든 것이 제대로 작동했습니다!

 
2018.07 . 25 20 : 42 : 35.261 Test_ind_1 (Si- 9.18 ,M1) OnInit : Indicator 1 - Подписка на стакан добавлена. Символ Si- 9.18
2018.07 . 25 20 : 42 : 35.261 Test_ind_1 (Si- 9.18 ,M1) OnInit : Indicator 1 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 42 : 35.261 Test_ind_1 (Si- 9.18 ,M1) OnInit : Indicator 1 - Book count: 1
2018.07 . 25 20 : 42 : 35.407 Test_ind_1 (Si- 9.18 ,M1) OnBookEvent :  Indicator 1 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 37.935 Test_ind_1 (Si- 9.18 ,M1) OnBookEvent :  Indicator 1 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 38.909 Test_ind_2 (Si- 9.18 ,M1) OnInit : Indicator 2 - Подписка на стакан добавлена. Символ Si- 9.18
2018.07 . 25 20 : 42 : 38.909 Test_ind_2 (Si- 9.18 ,M1) OnInit : Indicator 2 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 42 : 38.909 Test_ind_2 (Si- 9.18 ,M1) OnInit : Indicator 2 - Book count: 2
2018.07 . 25 20 : 42 : 39.053 Test_ind_1 (Si- 9.18 ,M1) OnBookEvent :  Indicator 1 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 39.053 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 39.195 Test_ind_1 (Si- 9.18 ,M1) OnBookEvent :  Indicator 1 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 43.127 Test_ind_3 (Si- 9.18 ,M1) OnInit : Indicator 3 - Подписка на стакан добавлена. Символ Si- 9.18
2018.07 . 25 20 : 42 : 43.127 Test_ind_3 (Si- 9.18 ,M1) OnInit : Indicator 3 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 42 : 43.127 Test_ind_3 (Si- 9.18 ,M1) OnInit : Indicator 3 - Book count: 3
2018.07 . 25 20 : 42 : 43.677 Test_ind_1 (Si- 9.18 ,M1) OnBookEvent :  Indicator 1 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 43.677 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 43.677 Test_ind_3 (Si- 9.18 ,M1) OnBookEvent : Indicator 3 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 44.066 Test_ind_1 (Si- 9.18 ,M1) OnBookEvent :  Indicator 1 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 44.066 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 44.066 Test_ind_3 (Si- 9.18 ,M1) OnBookEvent : Indicator 3 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 52.281 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Indicator 1 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 42 : 52.281 Test_ind_1 (Si- 9.18 ,M1) OnDeinit : Indicator 1 - Book count: 2
2018.07 . 25 20 : 42 : 52.533 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 52.533 Test_ind_3 (Si- 9.18 ,M1) OnBookEvent : Indicator 3 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 52.579 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 52.579 Test_ind_3 (Si- 9.18 ,M1) OnBookEvent : Indicator 3 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 52.779 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 52.779 Test_ind_3 (Si- 9.18 ,M1) OnBookEvent : Indicator 3 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 42 : 59.417 Test_ind_3 (Si- 9.18 ,M1) OnDeinit : Indicator 3 - Счётчик подписок обновлён. Символ Si- 9.18
2018.07 . 25 20 : 42 : 59.417 Test_ind_3 (Si- 9.18 ,M1) OnDeinit : Indicator 3 - Book count: 1
2018.07 . 25 20 : 42 : 59.946 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 43 : 00.786 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 43 : 07.775 Test_ind_2 (Si- 9.18 ,M1) OnBookEvent :  Indicator 2 - Подписка работает. Символ Si- 9.18
2018.07 . 25 20 : 43 : 07.977 Test_ind_2 (Si- 9.18 ,M1) OnDeinit : Indicator 2 - Подписка на стакан удалена. Символ Si- 9.18
2018.07 . 25 20 : 43 : 07.977 Test_ind_2 (Si- 9.18 ,M1) OnDeinit : Indicator 2 - Счётчик подписок удален. Символ Si- 9.18
즐기다.
 
prostotrader :
즐기다.

이것은 프로그램이 다른 공급업체에서 제공되고 공통 제어가 없는 일반적인 경우에는 도움이 되지 않습니다. 따라서 탬버린과 함께하는 이러한 모든 춤은 처음에는 쓸모가 없습니다. 그리고 이것은 이미 앞에서 말한 바 있습니다. 범람된 주제를 벗어난 스레드입니다.