Fragen von Neueinsteigern zu MQL4 und MQL5, Hilfe und Diskussion über Algorithmen und Codes - Seite 305

 
mila.com:

Danke, aber ich erhalte kein Ergebnis. Was könnte der Grund dafür sein?

Einen anderen Grund kann es nicht geben. Kein Computer kennt ein Jahr weniger als 1970. Beginnen Sie mit dem Jahr, das in den Angeboten des Maklers erscheint.

 
Alexey Viktorov:

Es könnte kein anderes Jahr sein. Kein Computer kennt ein Jahr weniger als 1970. Beginnen Sie mit dem Jahr, das in den Angeboten des Maklers erscheint.

Es ist ein guter Job, das erste Jahr unserer Ära.)

 
Vitaly Muzichenko:

Was ist los, es ist gut, das erste Jahr unserer Ära)

Und -1 wäre das erste Jahr BC.
 
Artyom Trishkin:
CopyXXX() verwenden

Ich danke Ihnen.


In MT5 können Sie den Chart auf diese Weise verschieben:

PlotIndexSetInteger(0,PLOT_SHIFT,InpChannelPeriod);

Wenn es in MT4 kompiliert wird, gibt es keine Fehler, aber nichts funktioniert, gibt es ein MT4 Gegenstück?
 
Aleksey Vyazmikin:

Ich danke Ihnen.


In MT5 ist es möglich, den Chart auf diese Weise zu verschieben:

PlotIndexSetInteger(0,PLOT_SHIFT,InpChannelPeriod);

Wenn Sie in MT4 kompilieren, gibt es keine Fehler, aber nichts funktioniert, gibt es ein MT4 Gegenstück?
Пользовательские индикаторы - Справочник MQL4
Пользовательские индикаторы - Справочник MQL4
  • docs.mql4.com
Пользовательские индикаторы - Справочник MQL4
 
Alexey Viktorov:

Ich habe dort gewählt.

SetIndexShift(0,InpChannelPeriod); 

aber der Effekt ist völlig anders, d.h. der Code funktioniert nicht, die Logik ist anders - ich weiß nicht...
 

Das Wesen des Indikators besteht darin, den Doncian-Kanal wie üblich zu zeichnen und dann die Linien des letzten Kanalwertes hinter den Minusbalken zu verschieben.

In MT5 scheint alles zu funktionieren, aber in MT4 verstehe ich nicht, was falsch ist - ich habe es hier und da neu gezeichnet, aber es zeichnet immer noch Unsinn - es verschiebt den Kanal selbst, obwohl ich separat Berechnung für Werte, die zu verschieben.... gehen wird

//+------------------------------------------------------------------+
//|                                             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:

Das Wesen des Indikators besteht darin, den Doncian-Kanal wie üblich zu zeichnen und dann die Linien des letzten Kanalwertes hinter den Minusbalken zu verschieben.

In MT5 scheint alles zu funktionieren, aber in MT4 verstehe ich nicht, was falsch ist - ich habe es hier und da neu gezeichnet, aber es zeichnet immer noch Unsinn - es verschiebt den Kanal selbst, obwohl ich separat Berechnung für Werte, die verschoben werden.... machen

Sehen Sie sich den Code des Alligators an, dort funktioniert die Verschiebung. Aber vielleicht ist die Logik eine andere.

 
Alexey Viktorov:

Schauen Sie sich den Alligator-Code an, dort funktioniert die Verschiebung. Die Logik könnte jedoch anders sein.


Ja, die Verschiebung funktioniert auch bei mir.

Ich fülle das Feld mit einer Verschiebung, aber es füllt sich, als ob es keine Verschiebung gäbe, aber die Verschiebung selbst geschieht visuell.

Der erste Teil des Codes lässt den Puffer bis zur Tiefe vonInpChannelPeriod des letzten Taktes ungefüllt:

   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)];

     }

Der zweite Teil sollte diesen Bereich ausfüllen:

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

In Wirklichkeit sieht es aber so aus:


 

Code im MT5

#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);
  }
//+------------------------------------------------------------------+

Ergebnis:


ZS: Der Code wurde geändert - der falsche ME war.
Grund der Beschwerde: