내 접근 방식. 코어 - 엔진. - 페이지 95

 
Реter Konow :

이미 그리고 노동 조합에서 이해했습니다.

끝까지 잘 이해하지 못했습니다.

옳지 않다:

Char_Uint u;
   uint width,height;
   string Message; 
   //-----------------------------
   if (! ResourceReadImage ( "\\Experts\\Tester EA.ex4::Resource" ,u.Uint,width,height)) Print ( "Failed to read resource!  " , GetLastError ());
   //-----------------------------
   Message = CharArrayToString (u.Char);
   //-----------------------------
   Print (Message);

바르게:

Char_Uint u;
   uint width,height;
   string Message; 
   //-----------------------------
   if (! ResourceReadImage ( "\\Experts\\Tester EA.ex4::Resource" ,u.Uint,width,height)) Print ( "Failed to read resource!  " , GetLastError ());
   //-----------------------------
   double bid = u.Double;
   //-----------------------------
   Print ( DoubleToString (bid));

그리고 코드에 어떤 문제가 있습니까? 당신은 수신자와 발신자에서 Char_Uint를 다르게 구성합니다!

 
Vasiliy Sokolov :

끝까지 잘 이해하지 못했습니다.

옳지 않다:

바르게:

그리고 코드에 어떤 문제가 있습니까? 당신은 수신자와 발신자에서 Char_Uint를 다르게 구성합니다!

고마워, 바실리. 필수인지 몰랐습니다. 그러나 구조가 동일한 옵션도 시도했습니다.

어쨌든 출력은 필요한 것이 아닙니다. 코드는 다음과 같습니다.

 //+------------------------------------------------------------------+
//|                                                    Tester EA.mq4 |
//|                                                      Peter Konow |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Peter Konow"
#property link        "https://www.mql5.com"
#property version    "1.00"
#property strict
//+------------------------------------------------------------------+
union Char_Uint
  {
   uchar    Char[ 8 ];
   uint     Uint[ 2 ];  
   double   Double; 
  };
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
   //----------------------------------------------
   if (! ObjectCreate ( 0 , "Resource" , OBJ_BITMAP_LABEL , 0 , 0 , 0 )) Print ( "Object is not created!  " , GetLastError ());
   else Print ( "Object created!" );
   //-------------------------------
   if (! ObjectSetString ( 0 , "Resource" , OBJPROP_BMPFILE , "::Resource" )) Print ( "BMPFILE is not created!" );
   else Print ( "BMPFILE created!" );
   //----------------------------------------------
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
//--- destroy timer
   
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
   //---------------------------
   Char_Uint u;
   //---------------------------
   u.Double = Bid ;
   //---------------------------
   if (! ResourceCreate ( "::Resource" ,u.Uint, 2 , 1 , 0 , 0 , 0 , COLOR_FORMAT_XRGB_NOALPHA )) Print ( "Resource is not created!" );
   //---------------------------   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer ()
  {
//---
   
  }
//+------------------------------------------------------------------+

그리고 받는 사람:

 //+------------------------------------------------------------------+
//|                                              Resource reader.mq4 |
//|                                                      Peter Konow |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Peter Konow"
#property link        "https://www.mql5.com"
#property version    "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
union Char_Uint
  {
   uchar    Char[ 8 ];
   uint     Uint[ 2 ];  
   double   Double; 
  };
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- indicator buffers mapping
   EventSetMillisecondTimer ( 5250 ); 
   
   if (! ObjectSetString ( 0 , "Resource" , OBJPROP_BMPFILE , "\\Experts\\Tester EA.ex4::Resource" )) Print ( "Resource is not connected!" );
   else Print ( "Resource connected!" );
//---
   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);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer ()
  {
  Char_Uint u;
   uint width,height;
   string Message; 
   //-----------------------------
   if (! ResourceReadImage ( "\\Experts\\Tester EA.ex4::Resource" ,u.Uint,width,height)) Print ( "Failed to read resource!  " , GetLastError ());
   //-----------------------------
   double bid = u.Double;
   //-----------------------------
   Print ( DoubleToString (bid, 5 ));
  }
//+------------------------------------------------------------------+

결과:

 2018.12 . 20 17 : 13 : 37.395 Resource reader GBPUSD,M5: 9223464270575144355.75808

하지만 적어도 변하지 않습니다. 값은 일정합니다. (비교 값의 변경과 함께 변경되어야 하지만).

 
Реter Konow :

그러나 적어도 그것은 변하지 않습니다. 값은 일정합니다. (비교 값의 변경과 함께 변경되어야 하지만).

귀하의 예제가 내 컴퓨터에서 올바르게 작동하기 때문에 이것은 매우 이상합니다. 두 전문가를 모두 만들어 두 개의 차트에 간단히 배치하십시오.

 
Vasiliy Sokolov :

귀하의 예제가 내 컴퓨터에서 올바르게 작동하기 때문에 이것은 매우 이상합니다. 두 전문가를 모두 만들어 두 개의 차트에 간단히 배치하십시오.

확인.

 

다음은 두 번째 차트의 두 번째 전문가 코드입니다. 결과는 똑같습니다...

 //+------------------------------------------------------------------+
//|                                                  Tester EA 2.mq4 |
//|                                                      Peter Konow |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Peter Konow"
#property link        "https://www.mql5.com"
#property version    "1.00"
#property strict
//+------------------------------------------------------------------+
union Char_Uint
  {
   uchar    Char[ 8 ];
   uint     Uint[ 2 ];  
   double   Double; 
  };
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- indicator buffers mapping
   
   if (! ObjectSetString ( 0 , "Resource" , OBJPROP_BMPFILE , "\\Experts\\Tester EA.ex4::Resource" )) Print ( "Resource is not connected!" );
   else Print ( "Resource connected!" );
//---
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTick ()
  {
  Char_Uint u;
   uint width,height;
   //-----------------------------
   if (! ResourceReadImage ( "\\Experts\\Tester EA.ex4::Resource" ,u.Uint,width,height)) Print ( "Failed to read resource!  " , GetLastError ());
   //-----------------------------
   double bid = u.Double;
   //-----------------------------
   Print ( DoubleToString (bid, 5 ));
  }
//+------------------------------------------------------------------+

제대로 작동하지 않습니다.

 
만일을 대비하여 내 소스는 다음과 같습니다.
파일:
 
Vasiliy Sokolov :
만일의 경우를 대비하여 내 소스는 다음과 같습니다.

아니요. 똑같다. 전문가 이름의 공백 때문이 아닐까요? 공백(자동 이름 바꾸기) 없이 다운로드했지만 공백이 있습니다. 지금 바로 변경하겠습니다.

 
Реter Konow :

아니요. 똑같다. 전문가 이름의 공백 때문이 아닐까요? 공백(자동 이름 바꾸기) 없이 다운로드했지만 공백이 있습니다. 지금 바로 변경하겠습니다.

노력하다. 공백의 사용은 매우 권장되지 않습니다. 이 나쁜 습관을 없애십시오.

 

씁니다:

 2018.12 . 20 17 : 46 : 26.798 Tester_EA_2 EURCHF,H1: 0.00000
2018.12 . 20 17 : 46 : 34.801 Tester_EA_2 EURCHF,H1: Failed to read resource!   4100
4100-

ERR_SOME_FILE_ERROR

 

이해했다. 파일을 읽는 동안 오류가 발생했습니다. 대시를 추가하는 것을 잊었습니다. 결과에 추가 및 반환:

 2018.12 . 20 17 : 55 : 24.590 Tester_EA_2 EURCHF,H1: 9223464270575144355.75808