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

 
Rustam Bikbulatov :

안녕하세요. 그가 ima= iMA ( NULL , 60 , 24 , 0 , 1 , 0 ,k) 가 보이지 않는 이유를 말해주세요. 주석을 통해 라인 자체보다 훨씬 높은 인용을 보여줍니다. 이 때문에 최소값과 최대값은 전혀 계산되지 않습니다.

숫자가 아니라 열거형의 식별자를 사용하십시오. 훨씬 더 명확:

 for (i=pos; i<rates_total && ! IsStopped (); i++)
     {
       double dmin= DBL_MAX ;
       double dmax=- DBL_MAX ;
       for (k=i-InpKPeriod+ 1 ; k<=i; k++)
        { double ima= iMA ( NULL , PERIOD_M1 , 60 , 0 , MODE_EMA , PRICE_CLOSE ,k);
         if (ima<dmin)  dmin=ima;
         if (ima>dmax)  dmax=ima;
         Comment ("pos="+( string )pos+", k="+( string )k+", iMA ="+ DoubleToString (ima, Digits ()));
        }
      ExtLowesBuffer[i]=dmin;
      ExtHighesBuffer[i]=dmax;
     }

iMA()를 요청하고 있음이 즉시 분명합니다. 예를 들어:

당신은 iMA(NULL,60,24,0,1,0,k)가 있습니다

그래서 iMA(NULL, PERIOD_H1,24,0 ,MODE_EMA,PRICE_CLOSE,k)

무엇이 더 명확합니까?

시간별 차트에서 Mashka 데이터를 가져옵니다. 프로그램이 시간별 차트로 실행되는 경우 어떤 종류의 데이터를 수신하고 볼 것으로 예상합니까?

 
Artyom Trishkin :

숫자가 아니라 열거형의 식별자를 사용하십시오. 훨씬 더 명확:

iMA()를 요청하고 있음이 즉시 분명합니다. 예를 들어:

당신은 iMA(NULL,60,24,0,1,0,k)가 있습니다

그래서 iMA(NULL, PERIOD_H1,24,0 ,MODE_EMA,PRICE_CLOSE,k)

무엇이 더 명확합니까?

시간별 차트에서 Mashka 데이터를 가져옵니다. 프로그램이 시간별 차트로 실행되는 경우 어떤 종류의 데이터를 수신하고 볼 것으로 예상합니까?

나는 이것을 분 차트에 넣었다.
   for (i=pos; i<rates_total && ! IsStopped (); i++)
     {
       double dmin= 1000000.0 ;
       double dmax=- 1000000.0 ;
       for (k=i-InpKPeriod+ 1 ; k<=i; k++)
        { double ima= iMA ( Symbol (), 1 , 60 , 0 , 1 , 0 ,k);
         if (dmin>ima)  dmin=ima;
         if (dmax<ima)  dmax=ima;
         Comment (dmax);
        }
      ExtLowesBuffer[i]=dmin;
      ExtHighesBuffer[i]=dmax;
     }

k와 함께 아무것도 나오지 않습니다

 
Rustam Bikbulatov :

실수로 설정되었습니다. 아무것도 변경되지 않습니다. k가 잘못된 것을 보여주는 바로 그 본질!

반쯤 자고 흐릿하지만 MA 값은 분명히 잘못된 쪽에서 가져옵니다 :-) 시간 프레임과의 혼동 외에도

   // основной цикл
   // перебираем бары от последнего нерасчитанного к актуальному
   // (просто пример - поэтому инициализация и заполнение буферов пропущенны!!)
   for ( int bar=prev_calculated;bar<rates_total && ! IsStopped ();bar++) {
       // bar использовать для обращения к массивам, i - к таймсериям
       int i=rates_total-bar- 1 ;
       // считаем min,max от некой MA за DEPTH баров
       double min= DBL_MAX ;
       double max= DBL_MIN ;
       if (bar<DEPTH) {
         // данных ещё недостаточно
         continue ;
      }
       for ( int t= 0 ;t<DEPTH;t++) {
         double ma= iMA ( _Symbol , _Period ,MA_PERIOD, 0 ,MA_METHOD,MA_PRICE,i+t); // берём значение MA (! как в таймсериях 0-последнее)
         if (ma> 0 ) {
             if (min<ma) min=ma;
             if (max>ma) max=ma;
         }
      }
       if (min!= DBL_MAX && max!= DBL_MIN ) {
         // что-то делаем с полученными максимум/минимум MA
      }
   }
 
Maxim Kuznetsov :

반쯤 자고 흐릿하지만 MA 값은 분명히 잘못된 쪽에서 가져옵니다 :-) 시간 프레임과의 혼동 외에도


흥미로운 아이디어입니다. 노력하겠습니다. 있다면 이것은 일반적인 확률적 지표 입니다. 이 아이디어는 모든 기간에 대한 막대의 극단과 MA 선의 극단을 취하는 것으로 나타났습니다. 100-113번 라인에 있습니다. 나는 이것이 지표를 향상시킬 것이라고 생각한다

 //+------------------------------------------------------------------+
///+------------------------------------------------------------------+
//|                                                   Stochastic.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright    "2005-2014, MetaQuotes Software Corp."
#property link          "http://www.mql4.com"
#property description "Stochastic Oscillator"
#property strict

#property indicator_separate_window
#property indicator_minimum      0
#property indicator_maximum      100
#property indicator_buffers      2
#property indicator_color1      LightSeaGreen
#property indicator_color2      Red
#property indicator_level1      20.0
#property indicator_level2      80.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
//--- input parameters
input int InpKPeriod= 60 ; // K Period
input int InpDPeriod= 60 ; // D Period
input int InpSlowing= 1 ; // Slowing
//--- buffers
double ExtMainBuffer[];
double ExtSignalBuffer[];
double ExtHighesBuffer[];
double ExtLowesBuffer[];
//---
int draw_begin1= 0 ;
int draw_begin2= 0 ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ( void )
  {
   string short_name;
//--- 2 additional buffers are used for counting.
   IndicatorBuffers ( 4 );
   SetIndexBuffer ( 2 , ExtHighesBuffer);
   SetIndexBuffer ( 3 , ExtLowesBuffer);
//--- indicator lines
   SetIndexStyle ( 0 , DRAW_LINE );
   SetIndexBuffer ( 0 , ExtMainBuffer);
   SetIndexStyle ( 1 , DRAW_LINE );
   SetIndexBuffer ( 1 , ExtSignalBuffer);
//--- name for DataWindow and indicator subwindow label
   short_name= "Sto(" + IntegerToString (InpKPeriod)+ "," + IntegerToString (InpDPeriod)+ "," + IntegerToString (InpSlowing)+ ")" ;
   IndicatorShortName (short_name);
   SetIndexLabel ( 0 ,short_name);
   SetIndexLabel ( 1 , "Signal" );
//---
   draw_begin1=InpKPeriod+InpSlowing;
   draw_begin2=draw_begin1+InpDPeriod;
   SetIndexDrawBegin ( 0 ,draw_begin1);
   SetIndexDrawBegin ( 1 ,draw_begin2);
//--- initialization done
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Stochastic oscillator                                            |
//+------------------------------------------------------------------+
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,k,pos;
//--- check for bars count
   if (rates_total<=InpKPeriod+InpDPeriod+InpSlowing)
       return ( 0 );
//--- counting from 0 to rates_total
   ArraySetAsSeries (ExtMainBuffer, false );
   ArraySetAsSeries (ExtSignalBuffer, false );
   ArraySetAsSeries (ExtHighesBuffer, false );
   ArraySetAsSeries (ExtLowesBuffer, false );
   ArraySetAsSeries (low, false );
   ArraySetAsSeries (high, false );
   ArraySetAsSeries (close, false );
//---
   pos=InpKPeriod- 1 ;
   if (pos+ 1 <prev_calculated)
      pos=prev_calculated- 2 ;
   else
     {
       for (i= 0 ; i<pos; i++)
        {
         ExtLowesBuffer[i]= 0.0 ;
         ExtHighesBuffer[i]= 0.0 ;
        }
     }
//--- calculate HighesBuffer[] and ExtHighesBuffer[]
   for (i=pos; i<rates_total && ! IsStopped (); i++)
     {
       double dmin= 1000000.0 ;
       double dmax=- 1000000.0 ;
       for (k=i-InpKPeriod+ 1 ; k<=i; k++)
        { double ima= iMA ( Symbol (), 1 , 60 , 0 , 1 , 0 ,k);
         if (dmin>ima)  dmin=ima;
         if (dmax<ima)  dmax=ima;
         Comment (ima);
        }
      ExtLowesBuffer[i]=dmin;
      ExtHighesBuffer[i]=dmax;
     }
//--- %K line
   pos=InpKPeriod- 1 +InpSlowing- 1 ;
   if (pos+ 1 <prev_calculated)
      pos=prev_calculated- 2 ;
   else
     {
       for (i= 0 ; i<pos; i++)
         ExtMainBuffer[i]= 0.0 ;
     }
//--- main cycle
   for (i=pos; i<rates_total && ! IsStopped (); i++)
     {
       double sumlow= 0.0 ;
       double sumhigh= 0.0 ;
       for (k=(i-InpSlowing+ 1 ); k<=i; k++)
        {
         sumlow +=(close[k]-ExtLowesBuffer[k]);
         sumhigh+=(ExtHighesBuffer[k]-ExtLowesBuffer[k]);
        }
       if (sumhigh== 0.0 )
         ExtMainBuffer[i]= 100.0 ;
       else
         ExtMainBuffer[i]=sumlow/sumhigh* 100.0 ;
     }
//--- signal
   pos=InpDPeriod- 1 ;
   if (pos+ 1 <prev_calculated)
      pos=prev_calculated- 2 ;
   else
     {
       for (i= 0 ; i<pos; i++)
         ExtSignalBuffer[i]= 0.0 ;
     }
   for (i=pos; i<rates_total && ! IsStopped (); i++)
     {
       double sum= 0.0 ;
       for (k= 0 ; k<InpDPeriod; k++)
         sum+=ExtMainBuffer[i-k];
      ExtSignalBuffer[i]=sum/InpDPeriod;
     }
//--- OnCalculate done. Return new prev_calculated.
   return (rates_total);
  }
//+------------------------------------------------------------------+
 

모두에게 좋은 하루!

예를 들어 오늘 Expert Advisor에서 설정을 지정하고 다음 날 일부 설정이 비어 있는 경우 어떻게 해야 합니까?

그리고 매일.

 
Valerius :

모두에게 좋은 하루!

예를 들어 오늘 Expert Advisor에서 설정을 지정하고 다음 날 일부 설정이 비어 있는 경우 어떻게 해야 합니까?

그리고 매일.

소스 코드가 있으면 코드에서 입력(또는 extern)을 제거하고 코드를 통해 매개변수를 변경합니다.

 
Valerius :

모두에게 좋은 하루!

예를 들어 오늘 Expert Advisor에서 설정을 지정하고 다음 날 일부 설정이 비어 있는 경우 어떻게 해야 합니까?

그리고 매일.

문제에 대해 가능한 한 많은 정보를 제공하여 서비스 데스크에 씁니다.

 
Nauris Zukas :

소스 코드가 있으면 코드에서 입력(또는 extern)을 제거하고 코드를 통해 매개변수를 변경합니다.


이것은 심각하지 않습니다. 왜 그것들(input 및 extern)이 필요한가요?

 
Artyom Trishkin :

문제에 대해 가능한 한 많은 정보를 제공하여 서비스 데스크에 씁니다.


왜 나에게 링크를 제공하지?

 
Valerius :

왜 나에게 링크를 제공하지?

그리고 프로필 좀 봐주세요... 재미있는게 많네요.