MQL4 ve MQL5 ile ilgili herhangi bir acemi sorusu, algoritmalar ve kodlar hakkında yardım ve tartışma - sayfa 305

 
mila.com :

Teşekkürler, ancak null döndürür. Nedeni ne olabilir?

Ve başkası olamaz. Hiçbir bilgisayar 1970'den daha az bir yıl bilemez. Aracı tarafından listelenen yılla başlayın.

 
Alexey Viktorov :

Ve başkası olamaz. Hiçbir bilgisayar 1970'den daha az bir yıl bilemez. Aracı tarafından listelenen yılla başlayın.

Ve normalde belirlenen, çağımızın ilk yılı)

 
Vitaly Muzichenko :

Eh, normalde ayarlanır, çağımızın ilk yılı)

A -1, MÖ ilk yıl olacak.
 
Artyom Trishkin :
CopyXXX() kullanın

Teşekkür ederim.


MT5'te grafiği şu şekilde değiştirebilirsiniz:

PlotIndexSetInteger(0,PLOT_SHIFT,InpChannelPeriod);

MT4'te derlerseniz hata vermiyor ama hiçbir şey çalışmıyor, MT4 için bir analog var mı?
 
Aleksey Vyazmikin :

Teşekkür ederim.


MT5'te grafiği şu şekilde değiştirebilirsiniz:

PlotIndexSetInteger(0,PLOT_SHIFT,InpChannelPeriod);

MT4'te derlerseniz hata vermiyor ama hiçbir şey çalışmıyor, MT4 için bir analog var mı?
Пользовательские индикаторы - Справочник MQL4
Пользовательские индикаторы - Справочник MQL4
  • docs.mql4.com
Пользовательские индикаторы - Справочник MQL4
 
Alexey Viktorov :

orada seçti

SetIndexShift(0,InpChannelPeriod); 

ancak, etki oldukça farklıdır, yani. kod çalışmıyor, mantık başka bir şey - xs ...
 

Belki birisi yardımcı olabilir, göstergenin özü Donchian kanalını her zamanki gibi çizmek ve ardından son kanal değerinin satırlarını negatif çubuğun arkasına taşımaktır.

MT5'te her şey çalışıyor gibi görünüyor, ancak MT4'te neyin yanlış olduğunu anlamıyorum - oraya buraya gönderdim, ancak sapkınlık çiziyor - değerlerin hesabını ayrı ayrı yapmama rağmen kanalın kendisini değiştiriyor bu kaydırılacak....

 //+------------------------------------------------------------------+
//|                                             Donchian_Channel.mq5 |
//+------------------------------------------------------------------+
#property copyright "Vyazmikin Aleksey Vyacheslavovich"
#property link        "https://www.mql5.com/ru/users/-aleks-"
#property version    "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots    2

//--- plot Label1
#property indicator_label1   "High_Prognoz" ;
#property indicator_type1   DRAW_LINE ;
#property indicator_color1   clrAquamarine ;
#property indicator_style1   STYLE_DOT ;
#property indicator_width1   1 ;
//--- plot Label2
#property indicator_label2   "Low_Prognoz" ;
#property indicator_type2   DRAW_LINE ;
#property indicator_color2   clrAquamarine ;
#property indicator_style2   STYLE_DOT ;
#property indicator_width2   1 ;


//--- input parameters
input int InpChannelPeriod= 48 ; // Period

//--- indicator buffers
double ExtHighBufferPrognoz[];
double ExtLowBufferPrognoz[];
//---
int i,limit,start;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,ExtHighBufferPrognoz, INDICATOR_DATA );
   SetIndexBuffer ( 1 ,ExtLowBufferPrognoz, INDICATOR_DATA );
//--- set accuracy
   IndicatorSetInteger ( INDICATOR_DIGITS , _Digits );
//--- set first bar from what index will be drawn
   SetIndexDrawBegin ( 0 ,InpChannelPeriod);
   SetIndexDrawBegin ( 1 ,InpChannelPeriod);

   SetIndexShift ( 0 ,InpChannelPeriod);
   SetIndexShift ( 1 ,InpChannelPeriod);

//---
   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[])
  {

//--- check for rates
   if (rates_total<InpChannelPeriod* 2 ) return ( 0 );
//--- preliminary calculations
   if (prev_calculated== 0 ) limit=InpChannelPeriod;
   else limit=prev_calculated;
//--- the main loop of calculations

   for (i=limit;i<rates_total && ! IsStopped ();i++)
     {
      start=i-InpChannelPeriod;
      ExtHighBufferPrognoz[i-InpChannelPeriod]=high[ ArrayMaximum (high,InpChannelPeriod,start)];
      ExtLowBufferPrognoz[i-InpChannelPeriod] =low[ ArrayMinimum (low,InpChannelPeriod,start)];

     }

   for ( int x=rates_total-InpChannelPeriod;x<rates_total && ! IsStopped ();x++)
     {
      ExtHighBufferPrognoz[x]=ExtHighBufferPrognoz[rates_total-InpChannelPeriod];
      ExtLowBufferPrognoz[x]=ExtLowBufferPrognoz[rates_total-InpChannelPeriod];
     }

//--- return value of prev_calculated for next call
   return (rates_total);
  }
 
Aleksey Vyazmikin :

Belki birisi yardımcı olabilir, göstergenin özü Donchian kanalını her zamanki gibi çizmek ve ardından son kanal değerinin satırlarını negatif çubuğun arkasına taşımaktır.

MT5'te her şey çalışıyor gibi görünüyor, ancak MT4'te neyin yanlış olduğunu anlamıyorum - oraya buraya gönderdim, ancak sapkınlık çiziyor - değerlerin hesabını ayrı ayrı yapmama rağmen kanalın kendisini değiştiriyor bu kaydırılacak....

Timsah koduna bak, vardiya orada çalışıyor. Gerçi, belki mantık farklıdır.

 
Alexey Viktorov :

Timsah koduna bak, vardiya orada çalışıyor. Gerçi, belki mantık farklıdır.


Evet, vardiya bende de işe yarıyor.

Diziyi bir kaydırma ile dolduruyorum, ancak doldurma kaydırmasız gibi çıkıyor, ancak kaydırmanın kendisi görsel olarak gerçekleşiyor.

Kodun ilk kısmı, arabelleği son çubuktan InpChannelPeriod derinliğine kadar boş bırakır:

   for (i=limit;i<rates_total && ! IsStopped ();i++)
     {
      start=i-InpChannelPeriod;
      ExtHighBufferPrognoz[i-InpChannelPeriod]=high[ ArrayMaximum (high,InpChannelPeriod,start)];
      ExtLowBufferPrognoz[i-InpChannelPeriod] =low[ ArrayMinimum (low,InpChannelPeriod,start)];

     }

Ve ikinci kısım bu bölümü daha önce doldurmalıdır:

   for ( int x=rates_total-InpChannelPeriod;x<rates_total && ! IsStopped ();x++)
     {
      ExtHighBufferPrognoz[x]=ExtHighBufferPrognoz[rates_total-InpChannelPeriod];
      ExtLowBufferPrognoz[x]=ExtLowBufferPrognoz[rates_total-InpChannelPeriod];
     }

Ama aslında şöyle oluyor:


 

MT5'teki kod

#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2

//--- plot Label1
#property indicator_label1  "Predicted_high_price";
#property indicator_type1   DRAW_LINE;
#property indicator_color1  clrAquamarine;
#property indicator_style1  STYLE_DOT;
#property indicator_width1  1;
//--- plot Label2
#property indicator_label2  "Predicted_low_price";
#property indicator_type2   DRAW_LINE;
#property indicator_color2  clrAquamarine;
#property indicator_style2  STYLE_DOT;
#property indicator_width2  1;


//--- input parameters
input int InpChannelPeriod=48; // Period

//--- indicator buffers
double ExtHighBufferPrognoz[];
double ExtLowBufferPrognoz[];
//---
int i,limit,start;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtHighBufferPrognoz,INDICATOR_DATA);
   SetIndexBuffer(1,ExtLowBufferPrognoz,INDICATOR_DATA);   
//--- set accuracy
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- set first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpChannelPeriod);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpChannelPeriod);   

   PlotIndexSetInteger(0,PLOT_SHIFT,InpChannelPeriod);
   PlotIndexSetInteger(1,PLOT_SHIFT,InpChannelPeriod);   


//---
   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[])
  {

//--- check for rates
   if(rates_total<InpChannelPeriod) return(0);
//--- preliminary calculations
   if(prev_calculated==0) limit=InpChannelPeriod;
   else limit=prev_calculated;
//--- the main loop of calculations
   for(i=limit;i<rates_total && !IsStopped();i++)
     {
      start=i-InpChannelPeriod;          
      ExtHighBufferPrognoz[i-InpChannelPeriod]=high[ArrayMaximum(high,start,InpChannelPeriod)];
      ExtLowBufferPrognoz[i-InpChannelPeriod]=low[ArrayMinimum(low,start,InpChannelPeriod)];

     }

   for(int x=rates_total-InpChannelPeriod;x<rates_total && !IsStopped();x++)
     {
      //int calc=x--;
      ExtHighBufferPrognoz[x]=ExtHighBufferPrognoz[rates_total-InpChannelPeriod-1];
      ExtLowBufferPrognoz[x]=ExtLowBufferPrognoz[rates_total-InpChannelPeriod-1];             
     }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Sonuç:


ZY: Kod değişti - o ME'den değil.