오류, 버그, 질문 - 페이지 936

 
#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  1
//--- input parameters
input string symbol1="AUDUSD";
input string symbol2="NZDUSD";
input double mass_of_symbol1=1;
input double mass_of_symbol2=1;


int i,r1,r2,j;
double S,prs,k1,k2,d1,d2;
//--- indicator buffers
double        ind1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ind1,INDICATOR_DATA);
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   ArraySetAsSeries(time,true);ArraySetAsSeries(open,true);ArraySetAsSeries(high,true);ArraySetAsSeries(low,true);
   ArraySetAsSeries(close,true);ArraySetAsSeries(tick_volume,true);ArraySetAsSeries(volume,true);ArraySetAsSeries(spread,true);

   ArraySetAsSeries(ind1,true);
   MqlRates rates1[]; ArraySetAsSeries(rates1,true);
   MqlRates rates2[]; ArraySetAsSeries(rates2,true);

   if(prev_calculated<rates_total)
     {
      for(i=0;i<rates_total;i++)
     // for(i=prev_calculated-1;i<rates_total;i++)
        {
         CopyRates(symbol1,0,time[i],1,rates1);
         CopyRates(symbol2,0,time[i],1,rates2);
         ind1[i]=mass_of_symbol1*rates1[0].close-mass_of_symbol2*rates2[0].close;
        }
     }



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

위의 코드는 Spread_of_symbols 표시기의 코드입니다... 더 빠르게 작동하도록 다시 실행하기로 결정했습니다. 코드는 아래를 참조하세요. 데이터가 복사되지 않습니다... 코드에서 데이터가 다음과 같은 경우 0이 아닌 1부터 복사하면 표시기가 매우 빠르게 그려지지만 범위를 벗어남 오류가 발생합니다. 코드에 무엇이 잘못되었습니까? 아래 참조...?

 #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   1
//--- input parameters
input string symbol1= "AUDUSD" ;
input string symbol2= "NZDUSD" ;
input double mass_of_symbol1= 1 ;
input double mass_of_symbol2= 1 ;


int i,r1,r2,j;
double S,prs,k1,k2,d1,d2;
//--- indicator buffers
double         ind1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,ind1, INDICATOR_DATA );
//---
   return ( 0 );
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   ArraySetAsSeries (time, true ); ArraySetAsSeries (open, true ); ArraySetAsSeries (high, true ); ArraySetAsSeries (low, true );
   ArraySetAsSeries (close, true ); ArraySetAsSeries (tick_volume, true ); ArraySetAsSeries (volume, true ); ArraySetAsSeries (spread, true );

   ArraySetAsSeries (ind1, true );
   MqlRates rates1[]; ArraySetAsSeries (rates1, true );
   MqlRates rates2[]; ArraySetAsSeries (rates2, true );
   
   int to_copy;
   if (prev_calculated>rates_total || prev_calculated< 0 ) to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
       if (prev_calculated> 0 ) 
      to_copy++;   
     }
   if ( CopyRates (symbol1, 0 , 0 ,to_copy,rates1)<= 0 )
     {
       Print ( "Данные по первому символу не скопированы, ошибка  " , GetLastError ());
       return ( 0 );
     }
   if ( CopyRates (symbol2, 0 , 0 ,to_copy,rates2)<= 0 )
     {
       Print ( "Данные по второму символу не скопированы, ошибка " , GetLastError ());
       return ( 0 );
     }
   if (prev_calculated<rates_total)
     {
     int limit;
   if (prev_calculated== 0 )
      limit= 0 ;
   else limit=prev_calculated- 1 ;
   for ( int i=limit;i<rates_total;i++)
        {
         ind1[i]=mass_of_symbol1*rates1[i].close-mass_of_symbol2*rates2[i].close;
        }
     }
   return (rates_total);
  }
 
FinEngineer :
MQL5 참조 / 시계열 및 지표 액세스 / 데이터 액세스 구성을 살펴보십시오.
 
FinEngineer : 하지만 범위를 벗어남 오류... 코드에 무엇이 잘못되었습니까? 아래 참조...?
to_copy 및 limit 변수의 값이 서로 어떻게 대응하는지 확인하십시오.
 
시각화 모드에서 두 개의 심볼을 거래할 때 동시에 거래를 마감한 후 Expert Advisor가 시작된 심볼의 데이터만 히스토리에 입력됩니다. 다른 기호에서 데이터는 다음 트랜잭션이 열린 후에만 기록 탭으로 이동합니다. 결과적으로 거래 및 내역 탭의 데이터가 다른 기간이 있습니다.
 
JF 0 거래 19:31:10 '***': 주문 취소 #3694236 매수 스톱 1.10 AUDJPY.m at 95.679
DS 0 거래 19:31:10 '***': 주문 취소 #3694238 구매 한도 1.10 AUDJPY.m at 93.876
DH 0 거래 19:31:10 '***': 주문 취소 #3694237 매수 스톱 0.36 AUDJPY.m at 95.679
FI 0 거래 19:31:10 '***': 주문 취소 #3694239 구매 한도 0.36 AUDJPY.m at 93.876
FP 0 거래 19:31:10 '***': 주문 취소 #3694236 1.10 AUDJPY.m에서 95.679 완료
QE 0 거래 19:31:11 '***': 주문 취소 #3694238 구매 한도 1.10 AUDJPY.m at 93.876 완료
CG 0 거래 19:31:11 '***': 주문 취소 #3694237 매수 스톱 0.36 AUDJPY.m at 95.679 완료
OL 0 거래 19:31:11 '***': 주문 취소 #3694239 구매 한도 0.36 AUDJPY.m at 93.876 완료

잡지에 따르면 4개의 보류 중인 주문 이 빠르게 사라진 것 같습니다. 그러나 OnTradeTransaction에서는 15초 만에 답이 나왔습니다. 이 기간 동안 정기적으로 틱이 왔습니다.

KH 0 prp5 (EURUSD.m,M1) 19:31:23 TS=6 삭제 sl _ OnTrade PENDING id=84 m=3 b/s=SELL Err=주문 완료
***

JG 0 prp5 (EURUSD.m,M1) 19:31:26 TS=6 삭제 tp _ OnTrade PENDING id=85 m=3 b/s=SELL Err=주문 완료
***
RL 0 prp5 (EURUSD.m,M1) 19:31:26 TS=6 삭제 sl _ OnTrade PENDING id=86 m=3 b/s=SELL Err=주문 완료
***

HK 0 prp5 (EURUSD.m,M1) 19:31:26 TS=6 삭제 tp _ OnTrade PENDING id=87 m=3 b/s=SELL Err=주문 완료

그런데 여기도 뭔가 이상하다

IE 0 prp5 (EURUSD.m,M1) 19:31:26 TS=6 =O= 거래 마감/반전 가격=95.648 m=3 b/s=SELL ... ==>OrderSendAsync 전 시간
ES 0 prp5 (EURUSD.m,M1) 19:31:29 TS=6 case 8(real) m=3 b/s=SELL Err=주문 접수 ==> OrderSendAsync 실행 후, 3초는 너무 많은 것 같습니다.

PS Expert Advisor의 실행에 제동이 걸렸지만 OnTradeTransaction 패키지가 대기열에 얼마나 오래 보관될 수 있는지는 흥미롭습니다.

 
fyords :

도움말에서:

MQL5 참조 / 표준 라이브러리 / 패널 및 대화 상자 생성을 위한 클래스 / CWnd / StateFlagsSet

어떤 속성?

StateFlagsSet은 속성이 아니라 상태입니다. 그룹 상태 변경 방법. 개별 상태 플래그를 변경하는 방법은 약간 더 높습니다.

별도로 사용하십시오.

 

"데이터 액세스 구성"을 살펴보고 데이터를 펌핑하고 모든 것을 이해하는 스크립트 예제를 보고 다음 질문이 생겼습니다.

1. OnInit 함수 의 표시기에 이 코드를 작성할 수 없는 이유는 무엇입니까? 그러면 시작될 때 표시기가 기록을 자체적으로 다운로드하고 시계열을 준비할 수 있습니다. Expert Advisor에서 그러한 수표를 처방할 수 있습니까?  

2. 얼마나 자주 유사한 점검을 수행해야 합니까? 1개의 전문가 고문, 2개의 지표? 복사를 위해 히스토리와 시계열을 한 번만 준비하면 앞으로 복사할 때 오류가 없을까요? 아니면 매번 또는 주기적으로 기록 및 시계열의 준비 상태를 확인해야 합니까?

3. 이 확인은 여러 기간 및 기호를 사용하는 지표 및 Expert Advisors에만 필요합니까, 아니면 모두에서 바람직합니까?

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - Документация по MQL5
 
페이징 프로세스는 비동기식이며 표시기는 데이터를 기다릴 권한이 없습니다. 따라서 인터넷에서 요청할 수 있습니다. 어떤 경우에도 기다리거나 속도를 늦추지 말고 oncalculate에서 존재와 개수만 확인하십시오.

참고 - 표시기는 기다리거나 순환할 권한이 없습니다. 그렇지 않으면 후속 표시기의 계산이 중단됩니다.
 
Renat :
페이징 프로세스는 비동기식이며 표시기는 데이터를 기다릴 권한이 없습니다. 따라서 인터넷에서 요청할 수 있습니다. 어떤 경우에도 기다리거나 속도를 늦추지 말고 oncalculate에서 존재와 개수만 확인하십시오.

참고 - 표시기는 기다리거나 순환할 권한이 없습니다. 그렇지 않으면 후속 표시기의 계산이 중단됩니다.

1 그럼 어디서 데이터를 페이징합니까? 쌍의 바스켓, 많은 기호가 있는 표시기를 만들려면 각 기호에 대해 데이터를 확인하고 업로드해야 합니다. ...에서 스크립트를 실행해야 합니다. 표시기 또는 무엇? 하나의 지표가 후속 지표의 계산을 중단시키는 이유는 무엇입니까? BarsCalculated (indicator1_Handle)를 통해 이전 지표의 계산을 확인하기 위해 후속 지표에서 사용하는 것으로 충분합니다. 자체적으로 계산하고 데이터를 펌핑하도록 두십시오. 아니면 제가 틀렸습니까?

2 그리고 다른 성격의 또 다른 질문으로, init 함수에서 표시기 핸들을 선언하면 계산이 시작됩니까? 아니면 복사하라는 명령을 내리기 전에 고려되기 시작합니까?