MQL4 및 MQL5에 대한 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론 - 페이지 672

 
inter78 :

사실 그렇게 하긴 했지만 긴 응답시간은 싫다.

작업은 길지 않지만 틱으로 ... 그러나 일반적으로 도움말을 읽기 시작하면 "포크 방법"을 사용하여 MQL을 공부할 수 없으며 MQL은 C ++ 기반이지만 다음과 연결되어 있습니다. MT플랫폼, 공부하지 않고는 방법이 없다

코드에서 파일로 작업하고 터미널 의 전역 변수로 작업하고 그래픽으로 작업하고 ... 그리고 모든 것이 한 틱에 여러 번 수행됩니다. 실제로 불필요한 작업이 많이 있습니다.

빠른 응답을 원하시면 OnChartEvent()를 사용하지만 테스터에서 생성되지 않지만 먼저 MQL4 도움말 공부를 시작하십시오

 
Igor Makanu :

작업은 길지 않지만 틱으로 ... 그러나 일반적으로 도움말을 읽기 시작하면 "포크 방법"을 사용하여 MQL을 공부할 수 없으며 MQL은 C ++ 기반이지만 다음과 연결되어 있습니다. MT플랫폼, 공부하지 않고는 방법이 없다

코드에서 파일로 작업하고 터미널 의 전역 변수로 작업하고 그래픽으로 작업하고 ... 그리고 모든 것이 한 틱에 여러 번 수행됩니다. 실제로 불필요한 작업이 많이 있습니다.

빠른 응답을 원하시면 OnChartEvent()를 사용하지만 테스터에서 생성되지 않지만 먼저 MQL4 도움말 공부를 시작하십시오

우리는 아마도 그것을 염두에 두도록 전문가에게 요청해야 할 것입니다. 나는 할 수 없습니다. 무제한의 열린 차트로 작업하기 위해 고통스럽게 편리한 정보 및 제어 지표로 밝혀졌습니다. 여기에서 버튼은 또한 해당 상품의 현재 이익과 매수 및 매도 주문 수를 나타냅니다.
 

안녕 모두.

코드 라이브러리에서 유용한 Ind-Fractals 표시기를 찾았습니다. 그러나 올바르게 계산하는 대신 모든 막대에 프랙탈을 그립니다. 표시기를 사용하고 싶지만 "깨진" 상태입니다(((오류를 찾도록 도와주세요. 작성자에게 연락을 시도했지만 메시지에 응답하지 않습니다. 편의를 위해 여기에 코드를 복사했습니다.

#property copyright "Copyright © 2005, MetaQuotes Software Corp."

#속성 링크 "http://www.metaquotes.net"

//----

#속성 표시기_차트_창

#속성 표시기_버퍼 8

#property indicator_color1 빨간색

#property indicator_color2 빨간색

#property indicator_color3 파란색

#property indicator_color4 파란색

#property indicator_color5 라임

#property indicator_color6 라임

#property indicator_color7 시에나

#property indicator_color8 시에나

//---- 입력 매개변수

extern bool Comm=true;

//---- 버퍼

이중 ExtMapBuffer1[];

이중 ExtMapBuffer2[];

이중 ExtMapBuffer3[];

이중 ExtMapBuffer4[];

이중 ExtMapBuffer5[];

이중 ExtMapBuffer6[];

이중 ExtMapBuffer7[];

이중 ExtMapBuffer8[];

//+----------------------------------------------- --------------------+

//| 사용자 지정 표시기 초기화 기능 |

//+----------------------------------------------- --------------------+

정수 초기화()

{

//---- 표시기

SetIndexStyle(0,DRAW_ARROW);//표시 선 스타일

SetIndexArrow(0.217); // 화살표 유형 설정

SetIndexBuffer(0,ExtMapBuffer1);//지정된 표시기 버퍼 를 이중 유형의 1차원 동적 배열과 연결합니다. 기능에는 2가지 옵션이 있습니다.

SetIndexEmptyValue(0,0.0);//표시줄의 빈 값을 설정합니다.

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1,218);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexEmptyValue(1,0.0);

SetIndexStyle(2,DRAW_ARROW);

SetIndexArrow(2,217);

SetIndexBuffer(2,ExtMapBuffer3);

SetIndexEmptyValue(2,0.0);

SetIndexStyle(3,DRAW_ARROW);

SetIndexArrow(3,218);

SetIndexBuffer(3,ExtMapBuffer4);

SetIndexEmptyValue(3,0.0);

SetIndexStyle(4,DRAW_ARROW);

SetIndexArrow(4,217);

SetIndexBuffer(4,ExtMapBuffer5);

SetIndexEmptyValue(4,0.0);

SetIndexStyle(5,DRAW_ARROW);

SetIndexArrow(5,218);

SetIndexBuffer(5,ExtMapBuffer6);

SetIndexEmptyValue(5,0.0);

SetIndexStyle(6,DRAW_ARROW);

SetIndexArrow(6,217);

SetIndexBuffer(6,ExtMapBuffer7);

SetIndexEmptyValue(6,0.0);

SetIndexStyle(7,DRAW_ARROW);

SetIndexArrow(7,218);

SetIndexBuffer(7,ExtMapBuffer8);

SetIndexEmptyValue(7,0.0);

리턴(0); }

//+----------------------------------------------- --------------------+

//| 고객 표시기 초기화 해제 기능 |

//+----------------------------------------------- --------------------+

int deinit() {반환(0); }

//------------------------------------------------ ------------------

bool 프랙탈(문자열 F, 정수 Per, 정수 시프트) {

if(Period()>Per) return(-1);

Per=Per/Period()*2+MathCeil(Per/Period()/2);

if(shift<Per)return(-1);

if(shift>bars-per)return(-1);

for(int i=1;i<=Per;i++) {

if(shift+i>=바 || shift-i<0) return(-1);

if(F=="U") {

if(High[shift+i]>High[shift])return(-1);

if(높음[shift-i]>=높음[shift])return(-1); }

if(F=="L") {

if(낮음[shift+i]<낮음[shift])return(-1);

if(낮음[shift-i]<=낮음[shift])return(-1); } }

반환(1); }

//------------------------------------------------ ------------------

정수 시작()

{

int D1=1440,H4=240,H1=60,M15=15,B;

이중 P;

int counted_bars=IndicatorCounted();// 표시기의 마지막 호출 이후 변경되지 않은 막대 수

B=막대-카운트된_막대;

if(counted_bars==0) B--;

if(Period()==D1)P=150*Point;// period는 현재 차트 기간을 반환합니다.

if(Period()==H4)P=70*점;

if(Period()==H1)P=40*포인트;

if(Period()==30)P=30*포인트;

if(Period()==M15)P=20*포인트;

if(Period()==5)P=10*포인트;

if(Period()==1)P=5*포인트;

for(int shift=B;shift>0;shift--)

{

if(Fractal("U",M15,shift)==1) ExtMapBuffer1[shift]=높음[shift]+P;

그렇지 않으면 ExtMapBuffer1[시프트]=0;

if(Fractal("L",M15,shift)==1) ExtMapBuffer2[shift]=낮음[shift]-P;

그렇지 않으면 ExtMapBuffer2[시프트]=0;

if(Fractal("U",H1,shift)==1) ExtMapBuffer3[shift]=높음[shift]+P;

그렇지 않으면 ExtMapBuffer3[시프트]=0;

if(Fractal("L",H1,shift)==1) ExtMapBuffer4[shift]=낮음[shift]-P;

그렇지 않으면 ExtMapBuffer4[시프트]=0;

if(Fractal("U",H4,shift)==1) ExtMapBuffer5[shift]=높음[shift]+P;

그렇지 않으면 ExtMapBuffer5[시프트]=0;

if(Fractal("L",H4,shift)==1) ExtMapBuffer6[shift]=낮음[shift]-P;

그렇지 않으면 ExtMapBuffer6[시프트]=0;

if(Fractal("U",D1,shift)==1) ExtMapBuffer7[shift]=높음[shift]+P;

그렇지 않으면 ExtMapBuffer7[시프트]=0;

if(Fractal("L",D1,shift)==1) ExtMapBuffer8[shift]=낮음[shift]-P;

그렇지 않으면 ExtMapBuffer8[시프트]=0;

}

if(Comm) Comment(" D1 - 갈색\n H4 - 녹색\n H1 - 파란색\nM15 - 빨간색 ");


리턴(0);

}

MetaQuotes Software Corp.
MetaQuotes Software Corp.
  • www.metaquotes.net
Миллионы трейдеров и сотни брокеров не могут ошибаться — они выбрали MetaTrader 5 для торговли на Форексе и финансовых рынках! Узнать больше
 

그런 코드 공급에 대해 그들은 여기에서 꾸짖습니다. 나는 처음으로 같은 것을 얻었습니다 :-)

Alt + S로 열리는 양식 에 코드를 삽입 해야 합니다.

 
psyman :

그런 코드 공급에 대해 그들은 여기에서 꾸짖습니다. 나는 처음으로 같은 것을 얻었습니다 :-)

Alt + S로 열리는 양식 에 코드를 삽입 해야 합니다.

꾸짖다? 어떠한 경우에도. 원하는 방식으로 코드를 작성하십시오. 그러나 ... 질문에 대한 답을 얻고 싶다면 도움을 요청하는 사람들을 존중하려고 노력하십시오. 모든 것이 간단합니다.

 

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

MQL4에 대한 모든 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론

Artyom Trishkin , 2018.10.18 08:07

이렇게 합시다. 편집기에서 표시기 템플릿을 만들고, 생성할 때 필요한 수의 입력 변수와 드로어블 버퍼를 추가합니다.

다음으로 특정 작업에서 수행해야 하는 작업을 분석합니다.

지난 번에는 변수와 배열의 이름만 변경했습니다.

iMA를 사용할 때 i-p는 양초에 100개 이상의 점이 있는 주와 요일에만 작동하며 더 작은 기간에는 아무 것도 그리지 않습니다. 반올림의 문제인 것 같습니다.




iMAOnArray를 사용하면 모든 TF에서 i-ra 창이 비어 있습니다. 로그에 오류가 없습니다.




 //+------------------------------------------------------------------+
//|                                                        _null.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link        "http://www.mql5.com"
#property version    "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots    1
//--- plot OC
#property indicator_label1    "O-C"
#property indicator_type1    DRAW_LINE
#property indicator_color1    clrSteelBlue
#property indicator_style1    STYLE_SOLID
#property indicator_width1    1
//--- indicator buffers
double          ip1Buf[];

input int ip1= 100 ;
double tmp1[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
  
IndicatorBuffers ( 2 );
string s_name1;

s_name1= "O-C (" + IntegerToString (ip1) + ")" ;

IndicatorShortName (s_name1);
SetIndexLabel ( 0 , s_name1);
SetIndexBuffer ( 1 , tmp1);


//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,ip1Buf);
   
//---
   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[])
  {


int i;

       Print ( "rates_total = " ,rates_total);
       for (i= 1 ; i<rates_total- 1 ; i++)
      {
       //Print("i = ",i);
      tmp1[i]= MathMax (open[i],close[i])- MathMin (open[i],close[i]);      
     // tmp1[i]=close[i];      
       //ip1Buf[i]=iMA(NULL,0,1,0,0,tmp1[i],0);
      ip1Buf[i]= iMAOnArray (tmp1, 1 , 1 , 0 , 0 , 0 );
      
      }
   
//--- return value of prev_calculated for next call
   return (rates_total);
  }
//+------------------------------------------------------------------+


 
psyman :

iMAOnArray를 사용하면 모든 TF에서 i-ra 창이 비어 있습니다. 로그에 오류가 없습니다.

여전히 기간이 1인 iMAOnArray()를 사용합니다. iMAOnArray() 값은 본질적으로 tmp1 배열의 값입니다.

당신이 생각하는 것을 이해하고 싶다면 루프를 더 짧게 만드십시오. for (i= 1 ; i<10 ; i++)

어떤 종류의 복잡한 공식을 계산하지 않고 iMAOnArray()를 사용하여 Mashka를 만들고 구축하는 것이 더 쉬울 수 있지만 계산하려는 모든 데이터를 인쇄합니다. iMA, iMAOnArray()는 동일한 계산입니다. .. 아아, 기술에 관한 질문이 이 포럼에서 답변될 수 있다면 오직 당신 자신만이 정보를 계산하고 다루는 법을 배워야 합니다

 
psyman :

지난 번에는 변수와 배열의 이름만 변경했습니다.

iMA를 사용할 때 i-p는 양초에 100개 이상의 점이 있는 주와 요일에만 작동하며 더 작은 기간에는 아무 것도 그리지 않습니다. 반올림의 문제인 것 같습니다.




iMAOnArray를 사용하면 모든 TF에서 i-ra 창이 비어 있습니다. 로그에 오류가 없습니다.





첫 번째 루프는 첫 번째 버퍼의 값을 계산합니다.

두 번째 사이클에서는 첫 번째 사이클에서 계산된 값을 사용하여 MA를 계산합니다.

iMAOnArray()가 의미하는 바를 생각해 보십시오. Array에 MA를 별도로 작성하십시오. 이것을 어떻게 번역할까요? 누구나 손에 Google 번역기가 있습니다. 배열에 in-translate-get: MA를 가져옵니다.

저것들. - 미리 계산되고 채워진 배열을 기반으로 하는 이동 평균.

따라서 첫 번째 주기는 필요한 배열을 준비하는 것이고 두 번째 주기는 첫 번째 주기에서 준비된 배열을 기반으로 이동 평균을 구성하는 것입니다.

뭐하세요? 첫 번째 배열에 값을 입력하고(나머지 값은 아직 준비되지 않음), 즉시 이 값에 대해 MA 빌드를 시도합니다.

내가 준 템플릿은 다음과 같습니다.

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

MQL4에 대한 모든 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론

Artyom Trishkin , 2018.10.18 09:39

지시자:

 //+------------------------------------------------------------------+
//|                                                       TestMA.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                             https://mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link        "https://mql5.com/ru/users/artmedia70"
#property version    "1.00"
#property indicator_chart_window
#ifdef __MQL4__
#property strict
#property indicator_buffers 2
#else 
#property indicator_buffers 3
#property indicator_plots    2
#endif 
//--- plot MAstd
#property indicator_label1    "Calculation MA"
#property indicator_type1    DRAW_LINE
#property indicator_color1    clrBlue
#property indicator_style1    STYLE_SOLID
#property indicator_width1    4
//--- plot MAcalc
#property indicator_label2    "Standart MA"
#property indicator_type2    DRAW_LINE
#property indicator_color2    clrDarkOrange
#property indicator_style2    STYLE_DOT
#property indicator_width2    2
//--- input parameters
input int       InpPeriod                     =   10 ;             // Period
input ENUM_MA_METHOD        InpMethod         =   MODE_EMA ;       // Method
input ENUM_APPLIED_PRICE    InpAppliedPrice   =   PRICE_CLOSE ;   // Applied price  
//--- indicator buffers
double          BufferMAcalc[];
double          BufferMAstd[];
double          BufferPrice[];
//---
int             digits;
int             period_ma;
int             handle_ma;
CAvg           avg();
//--- includes

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//---
#ifdef __MQL4__
   IndicatorBuffers ( 3 );
#endif 
   period_ma=(InpPeriod< 1 ? 1 : InpPeriod);
   digits= Digits ()+ 1 ;
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,BufferMAcalc, INDICATOR_DATA );
   SetIndexBuffer ( 1 ,BufferMAstd, INDICATOR_DATA );
   SetIndexBuffer ( 2 ,BufferPrice, INDICATOR_CALCULATIONS );
//---
   ArraySetAsSeries (BufferMAcalc, true );
   ArraySetAsSeries (BufferMAstd, true );
   ArraySetAsSeries (BufferPrice, true );
//---
#ifdef __MQL5__
   ResetLastError ();
   handle_ma= iMA ( NULL , PERIOD_CURRENT ,period_ma, 0 ,InpMethod,InpAppliedPrice);
   if (handle_ma== INVALID_HANDLE )
     {
       Print ( "Error creation iMA(" ,( string )period_ma, "): " , GetLastError ());
       return INIT_FAILED ;
     }
#endif 
//---
   Comment ( "\nMA type: " ,avg.MethodToString(InpMethod), ", price: " ,avg.PriceToString(InpAppliedPrice), ", period: " ,( string )period_ma);
//---
   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[])
  {
//--- Установка массивов буферов как таймсерий
#ifdef __MQL5__
   ArraySetAsSeries (open, true );
   ArraySetAsSeries (high, true );
   ArraySetAsSeries (low, true );
   ArraySetAsSeries (close, true );
#endif 
//--- Проверка количества доступных баров
   if (rates_total< fmax (period_ma, 4 )) return 0 ;
//--- Проверка и расчёт количества просчитываемых баров
   int limit=rates_total-prev_calculated;
   if (limit> 1 )
     {
      limit=rates_total- 1 ;
       ArrayInitialize (BufferMAcalc, EMPTY_VALUE );
       ArrayInitialize (BufferMAstd, EMPTY_VALUE );
       ArrayInitialize (BufferPrice,0);
     }
//--- Подготовка данных
#ifdef __MQL5__
   int count=(limit> 1 ? rates_total : 1 ),copied= 0 ;
   copied= CopyBuffer (handle_ma, 0 , 0 ,count,BufferMAstd);
   if (copied!=count) return 0 ;
#endif 
//--- Расчёт индикатора
   for ( int i=limit; i>= 0 && ! IsStopped (); i--)
     {
       #ifdef __MQL4__ BufferMAstd[i]= iMA ( NULL , PERIOD_CURRENT ,period_ma, 0 ,InpMethod,InpAppliedPrice,i); #endif 
       BufferPrice[i]=avg.AppliedPrice(InpAppliedPrice, NULL , PERIOD_CURRENT ,i);
      BufferMAcalc[i]=avg.GetMA(rates_total,InpMethod,period_ma,i,BufferPrice);
     }

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

그것에서 5와 관련된 모든 것을 버리고 4를 위한 템플릿을 얻을 수 있습니다. 이 템플릿은 다중 플랫폼이지만 한 번에 두 터미널 모두에 사용할 수 있습니다. 고유한 버퍼와 해당 번호를 설정하기만 하면 됩니다. 이 템플릿에는 두 가지가 그려지고 한 가지가 계산되어 여기에서 볼 수 있습니다.

 //--- indicator buffers mapping
   SetIndexBuffer ( 0 ,BufferMAcalc, INDICATOR_DATA );
   SetIndexBuffer ( 1 ,BufferMAstd, INDICATOR_DATA );
   SetIndexBuffer ( 2 ,BufferPrice, INDICATOR_CALCULATIONS );
//---
 

= 여전히, iMAOnArray()를 기간 1로 사용합니다. 즉, iMAOnArray() 값은 본질적으로 tmp1 배열의 값입니다.


나는 사용하기 위해 다른 값을 시도했지만 1은 이 실험의 마지막 옵션으로 남았습니다.

어떤 이유로 모든 TF의 i-ra 버퍼에 동일한 숫자가 기록됩니다(예: ip1Buf[4] = 2147483647.0). 반면 배열 값은 모두 다른 tmp1[4] = 0.1300000000000097 등입니다.

단, 이 경우에도 직선을 그려야 하며, i-ra 차트에는 전혀 아무것도 없고, 척도는 0에서 0까지 표시되어 있다.



 
psyman :

= 여전히, iMAOnArray()를 기간 1로 사용합니다. 즉, iMAOnArray() 값은 본질적으로 tmp1 배열의 값입니다.


나는 사용하기 위해 다른 값을 시도했지만 1은 이 실험의 마지막 옵션으로 남았습니다.

어떤 이유로 모든 TF의 i-ra 버퍼에 동일한 숫자가 기록됩니다. 예를 들어 ip1Buf[4] = 2147483647.0인 반면 배열 값은 모두 다른 tmp1[4] = 0.13000000000000097 등입니다.

단, 이 경우에도 직선을 그려야 하며, i-ra 차트에는 전혀 아무것도 없고, 척도는 0에서 0까지 표시되어 있다.



2147483647.0 자, 검색을 시작해보세요! https://www.mql5.com/ru/forum/224831

다시 한번, 나는 Artem이 썼습니다, 당신은 스스로 읽을 필요가 있습니다. 간단한 것부터 시작하십시오 ... 표시기로 차트에 종가를 그린 다음 그것을 복잡하게 시도하고 한 사이클에서 동일하게 수행하십시오. 두 번째 사이클에서 가까운 위치에 있는 이미 계산된 버퍼에 대한 MA를 계산합니다.

2147483647 в буфере
2147483647 в буфере
  • 2018.01.15
  • www.mql5.com
День Добрый! Подскажите, пожалуйста, что это за хрень. Не первый раз сталкиваюсь...