Fragen von Anfängern MQL5 MT5 MetaTrader 5 - Seite 1484

 
Novichokkk #:

14 ist binär. Sie lautet 1110.

Verschieben Sie ein Bit nach links zu 0111,

wir haben verschiedene "Linke" :-)

1110<<1 := 11100

 
Maxim Kuznetsov #:

Sie und ich haben unterschiedliche "Linke" :-)

1110<<1 := 11100

Ich habe es im Internet gelesen. Das ist für 32 Bits, so wie ich es verstehe, für 16 ist es dasselbe, nichts ist um ein Bit gesprungen. Aber ich lerne gerade, wahrscheinlich hast du recht.

Es geht nicht darum, es ist nur eine Randnotiz. Ich war von einer solchen Konstruktion im Terminal überrascht. Dieser Indikator ist nicht einmal aus der Codebase, sondern aus dem Terminal aus dem Ordner Examples.

Dateien:
8888.jpg  49 kb
 

Wie ändert man ein altes Design?

ObjectSetText("Maximum",DoubleToString(ChartGetDouble(0,CHART_PRICE_MAX,0),5),8,"Arial",Red);

Hier ist alles klar: So und so ein Objekt, so und so beschreiben, so und so eine Schriftgröße, Schriftart, Farbe.

Aber das ist vom alten Design.

Ich lese, was ersetzt wird

ObjectSetText

Auf

ObjectGetInteger,ObjectSetString,ObjectSetIntegerStringLen.

Aber in all diesen Funktionen gibt es keine solchen Parameter wie in ObjectSetText.

Документация по MQL5: Графические объекты / ObjectGetInteger
Документация по MQL5: Графические объекты / ObjectGetInteger
  • www.mql5.com
ObjectGetInteger - Графические объекты - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

Ich hatte diesen Code auf µl4

int OnInit()
  {
   SetIndexBuffer(0,H);
   SetIndexStyle(0,2);
   SetIndexBuffer(1,L);
   SetIndexStyle(1,2);

   if(ObjectCreate("Maximum",OBJ_LABEL,0,0,0))
     {
      ObjectSet("Maximum",OBJPROP_XDISTANCE,1);
      ObjectSet("Maximum",OBJPROP_YDISTANCE,1);
      ObjectSet("Maximum",OBJPROP_CORNER,1);
     }
   ObjectSetText("Maximum",DoubleToStr(WindowPriceMax(),4),8,"Arial",Red);

   if(ObjectCreate("Minimum",OBJ_LABEL,0,0,0))
     {
      ObjectSet("Minimum",OBJPROP_XDISTANCE,1);
      ObjectSet("Minimum",OBJPROP_YDISTANCE,1);
      ObjectSet("Minimum",OBJPROP_CORNER,3);
     }
   ObjectSetText("Minimum",DoubleToStr(WindowPriceMin(),4),8,"Arial",Blue);

   return(0);
  }



Ich änderte ihn auf µl5, nur ObjectSetText verstand ich nicht, wie ich ihn ändern sollte.


int OnInit()
  {
   SetIndexBuffer(0, H, INDICATOR_DATA);
   PlotIndexSetInteger(1,5,0);
   SetIndexBuffer(1, L, INDICATOR_DATA);
   PlotIndexSetInteger(2,5,0);

   if(ObjectCreate(0,"Maximum",OBJ_LABEL,0,0,0))
     {
      ObjectSetInteger(0,"Maximum",OBJPROP_XDISTANCE,1);
      ObjectSetInteger(0,"Maximum",OBJPROP_YDISTANCE,1);
      ObjectSetInteger(0,"Maximum",OBJPROP_CORNER,1);
     }
   ObjectSetText("Maximum",DoubleToString(ChartGetDouble(0,CHART_PRICE_MAX,0),5),8,"Arial",Red);

   if(ObjectCreate(0,"Minimum",OBJ_LABEL,0,0,0))
     {
      ObjectSetInteger(0,"Minimum",OBJPROP_XDISTANCE,1);
      ObjectSetInteger(0,"Minimum",OBJPROP_YDISTANCE,1);
      ObjectSetInteger(0,"Minimum",OBJPROP_CORNER,3);
     }
   ObjectSetText("Minimum",DoubleToString(ChartGetDouble(0,CHART_PRICE_MIN,0),5),8,"Arial",Blue);

   return(0);
  }
 
Novichokkk #:

Wie kann man ein altes Design ändern?

Hier ist alles klar: Wir beschreiben dieses und jenes Objekt in dieser und jener Schriftgröße, Schriftart, Farbe.

Aber das ist vom alten Design.

Ich lese, was ersetzt wird

An

ObjectGetInteger,ObjectSetString,ObjectSetIntegerStringLen

Aber in all diesen Funktionen gibt es keine solchen Parameter wie in ObjectSetText.

Schriftart, Größe, Farbe, Hintergrundfarbe usw. werden durch separate Aufrufe von https://www.mql5.com/ru/docs/constants/objectconstants/enum_object_property eingestellt .

 
JRandomTrader #:

Schriftart, Größe, Farbe, Hintergrundfarbe usw. werden durch separate Aufrufe von https://www.mql5.com/ru/docs/constants/objectconstants/enum_object_property festgelegt .

Anstelle von

ObjectSetText("Maximum",DoubleToStr(WindowPriceMax(),4),8,"Arial",Red);

Soll ich das so machen?

    ObjectSetString(0,"Maximum",OBJPROP_TEXT,DoubleToString(ChartGetDouble(0,CHART_PRICE_MAX,0),5)); // описание-что вставляем в объект "Maximum"
    ObjectSetString(0,"Maximum",OBJPROP_FONTSIZE,8);    // размер шрифта описания                                      
    ObjectSetString(0,"Maximum",OBJPROP_FONT,"Arial");  // какой шрифт
    ObjectSetString(0,"Maximum",OBJPROP_COLOR,Red);     // цвет шрифта
 
Novichokkk #:

Anstatt also

Müssen Sie das tun?

OBJPROP_FONTSIZE und OBJPROP_COLOR - über ObjectSetInteger()

Anstelle von DoubleToString() ist es manchmal bequemer, StringFormat() zu verwenden, da man das Format flexibler steuern kann.

 

Warum gibt dieses Skript 196

//+------------------------------------------------------------------+
//|                                                         0000.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()

  {
//---
   Alert((int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR));
   
  }
//+------------------------------------------------------------------+

und dieses 104 aus.

//+------------------------------------------------------------------+
//|                                                         0000.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()

  {
//---
   Alert(CHART_FIRST_VISIBLE_BAR);
   
  }
//+------------------------------------------------------------------+

Das Ergebnis sollte dasselbe sein.

 
Novichokkk #:

Warum gibt ein solches Skript 196

Und dieses hier 104.

Das Ergebnis sollte das gleiche sein.

Warum sollte es dasselbe sein?

Im ersten Fall geht es darum, den Wert der Eigenschaftsnummer CHART_FIRST_VISIBLE_BAR des aktuellen Diagramms zu ermitteln.

Im zweiten Fall geht es darum, die Nummer dieser Eigenschaft selbst zu ermitteln.

Grob gesagt, ist der Unterschied derselbe wie zwischen dem Wert einer Array-Zelle und dem Index dieser Zelle.

 


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 OrangeRed

extern int Ratio=2;
int limit;
int limitBars=0;

double H[];
double L[];
//+------------------------------------------------------------------+ 
int init()
{
   SetIndexBuffer(0,H); SetIndexStyle(0,2);
   SetIndexBuffer(1,L); SetIndexStyle(1,2);

   if(ObjectCreate("Maximum",OBJ_LABEL,0,0,0))  {
      ObjectSet("Maximum",OBJPROP_XDISTANCE,1);
      ObjectSet("Maximum",OBJPROP_YDISTANCE,1);
      ObjectSet("Maximum",OBJPROP_CORNER,1);  }
   ObjectSetText("Maximum",DoubleToStr(WindowPriceMax(),4),8,"Arial",Red);

   if(ObjectCreate("Minimum",OBJ_LABEL,0,0,0))  {
      ObjectSet("Minimum",OBJPROP_XDISTANCE,1);
      ObjectSet("Minimum",OBJPROP_YDISTANCE,1);
      ObjectSet("Minimum",OBJPROP_CORNER,3);  }
   ObjectSetText("Minimum",DoubleToStr(WindowPriceMin(),4),8,"Arial",Blue);

   return(0);
}
//+------------------------------------------------------------------+ 
int start()
{
   double max[256];
   double min[256];

   if(limitBars<Bars) limit=WindowFirstVisibleBar();

   for(int i=0; i<limit; i++)
   {
      for(int shift=0; shift<Ratio; shift++) {
         max[shift]=High[i*Ratio+shift];
         min[shift]=Low[i*Ratio+shift];   }

      H[i]=max[ArrayMaximum(max,Ratio,0)];
      L[i]=min[ArrayMinimum(min,Ratio,0)];
   }

   if(limit>1)
   {
      max[0]=H[ArrayMaximum(H,limit,0)];
      min[0]=L[ArrayMinimum(L,limit,0)];
      ObjectSetText("Maximum",DoubleToStr(max[0],4));
      ObjectSetText("Minimum",DoubleToStr(min[0],4));
   }

   limitBars=Bars;
   limit=1;
   return(0);
}

Auf dem alten MQL4 gab es einen solchen Indikator.
Grund der Beschwerde: