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

 
de_leonid:

Ich danke Ihnen für Ihre Hilfe. Kann ich auch fragen, für ein Beispiel der EA (Teil des Codes) auf, wie man Wert von diesen Zeilen in EA erhalten.

Ich habe für mich einen Expert Advisor https://www.mql5.com/ru/code/34046- erstellt, der Operationen auf horizontalen oder Trendlinien durchführen kann

Sie müssen den Namen der horizontalen Linien ausTymen_STARC_Bands_MTF kennen

Hier sind ihre Namen

string   m_r2_name      = "Highest";
string   m_r1_name      = "Top";
string   m_0_name       = "Middle";
string   m_s1_name      = "Bottom";
string   m_s2_name      = "Lowest";

und geben sie in den Expert Advisor ein und setzen den Befehl

hier

sinput group "----------------- Trade Line UP ------------------------"
sinput ENUM_MODE          FilterLine_13              = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput ENUM_TIMEFRAMES    InpPeriod_Up               = PERIOD_CURRENT;   // Period
sinput ENUM_TRADE_COMMAND InpCommandOpenedUp         = open_buy;         // Trade command:
sinput string             InpNameAverageUp           = "Line Up";        // Line Name UP(Horizontal Line or Trend Line)
sinput ENUM_TRADE_COMMAND InpCommandOpenedUpLow      = open_sell;        // Trade command:
sinput bool               InpDelLineUp               = false;            // Delete (Horizontal Line or Trend Line)
sinput double             InpObjStepTradeUp          = 0;                // Obj: Distance from price to object, in pips
sinput color              InpObjAverageclrUp         = clrBlue;          // EA only monitors this lines color
sinput group "----------------- Trade Line_2 UP ----------------------"
sinput ENUM_MODE          FilterLine_15              = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput ENUM_TIMEFRAMES    InpPeriod_Up_2             = PERIOD_CURRENT;   // Period
sinput ENUM_TRADE_COMMAND InpCommandOpenedUp_2       = open_buy;         // Trade command:
sinput string             InpNameAverageUp_2         = "Line_2 Up";      // Line Name UP(Horizontal Line or Trend Line)
sinput ENUM_TRADE_COMMAND InpCommandOpenedUpLow_2    = open_sell;        // Trade command:
sinput bool               InpDelLineUp_2             = false;            // Delete (Horizontal Line or Trend Line)
sinput double             InpObjStepTradeUp_2        = 0;                // Obj: Distance from price to object, in pips
sinput color              InpObjAverageclrUp_2       = clrBlue;          // EA only monitors this lines color
sinput group "----------------- Trade Line DOWN ----------------------"
sinput ENUM_MODE          FilterLine_14              = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput ENUM_TIMEFRAMES    InpPeriod_Down             = PERIOD_CURRENT;   // Period
sinput ENUM_TRADE_COMMAND InpCommandOpenedDown       = open_buy;         // Trade command:
sinput string             InpNameAverageDown         = "Line Down";      // Line Name DOWN(Horizontal Line or Trend Line)
sinput ENUM_TRADE_COMMAND InpCommandOpenedDownLow    = open_sell;        // Trade command:
sinput bool               InpDelLineDown             = false;            // Delete (Horizontal Line or Trend Line)
sinput double             InpObjStepTradeDown        = 0;                // Obj: Distance from price to object, in pips
sinput color              InpObjAverageclrDown       = clrRed;           // EA only monitors this lines color
sinput group "----------------- Trade Line_2 DOWN --------------------"
sinput ENUM_MODE          FilterLine_16              = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput ENUM_TIMEFRAMES    InpPeriod_Down_2           = PERIOD_CURRENT;   // Period
sinput ENUM_TRADE_COMMAND InpCommandOpenedDown_2     = open_buy;         // Trade command:
sinput string             InpNameAverageDown_2       = "Line_2 Down";    // Line Name DOWN(Horizontal Line or Trend Line)
sinput ENUM_TRADE_COMMAND InpCommandOpenedDownLow_2  = open_sell;        // Trade command:
sinput bool               InpDelLineDown_2           = false;            // Delete (Horizontal Line or Trend Line)
sinput double             InpObjStepTradeDown_2      = 0;                // Obj: Distance from price to object, in pips
sinput color              InpObjAverageclrDown_2     = clrRed;           // EA only monitors this lines color
Algorithm manually automate
Algorithm manually automate
  • www.mql5.com
Эксперт для Автоматизации Ручной торговли.
 
de_leonid:

Ich danke Ihnen für Ihre Hilfe. Kann ich auch fragen, für ein EA-Beispiel (Teil des Codes), wie man den Wert aus diesen Zeilen in EA zu erhalten.

die Funktion selbst in Expert Advisor von Horizontal oder Trendlinie

Hier -(gelb markiert - hier wird der Name der Linie gesetzt ) \\\\\\\\\\\\ für 1-Minuten-Test - setzen Sie manuell eine horizontale oder Trendlinie, setzen Sie den gleichen Namen in Expert Advisor und in der Linie selbst.

//+------------------------------------------------------------------+
//|                                                TrendOpenedUp.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//---
sinput string InpNameAverageUp = "Line Up"; // Line Name UP(Horizontal Line or Trend Line)
sinput bool   InpDelLineUp     = false;     // Delete (Horizontal Line or Trend Line)
//---
datetime ExtPrevBarsUp;    // "0" -> D'1970.01.01 00:00';
datetime ExtLastAverageUp; // "0" -> D'1970.01.01 00:00';
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   TrendOpenedUp();
  }
//+------------------------------------------------------------------+
//| Check for long position opening                                  |
//+------------------------------------------------------------------+
bool TrendOpenedUp(void)
  {
   bool res=false;
   datetime time_0=iTime(Symbol(),Period(),0);
   if(time_0==ExtPrevBarsUp)
      return(true);
   ExtPrevBarsUp=time_0;
     {
      if(ObjectFind(0,InpNameAverageUp)<0)
         return(true);
      MqlRates ratesAverage[];
      ArraySetAsSeries(ratesAverage,true);
      int start_pos=0,count=3;
      if(CopyRates(Symbol(),Period(),start_pos,count,ratesAverage)!=count)
         return(false);
      if(ratesAverage[0].time==ExtLastAverageUp)
         return(true);
      double price_line=0.0;
      long object_type=ObjectGetInteger(0,InpNameAverageUp,OBJPROP_TYPE);
      if(object_type==OBJ_HLINE)
         price_line=ObjectGetDouble(0,InpNameAverageUp,OBJPROP_PRICE);
      else
         if(object_type==OBJ_TREND)
            price_line=ObjectGetValueByTime(0,InpNameAverageUp,ratesAverage[1].time,0);
      double value_by_time=price_line;
      if(value_by_time==0.0)
         return(true);
      if(ratesAverage[1].open<value_by_time && ratesAverage[1].close>value_by_time)
        {
         PlaySound("request.wav");
         if(InpDelLineUp)
            ObjectsDeleteAll(0,InpNameAverageUp);
         res=true;
        }
      if(ratesAverage[1].open>value_by_time && ratesAverage[1].close<value_by_time)
        {
         PlaySound("tick.wav");
         if(InpDelLineUp)
            ObjectsDeleteAll(0,InpNameAverageUp);
         res=true;
        }
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
 
de_leonid:

Ich danke Ihnen für Ihre Hilfe. Kann ich auch fragen, für ein EA-Beispiel (Teil des Codes), wie man den Wert aus diesen Zeilen in EA zu erhalten.

Am einfachsten ist es, die Namen der Horizontal- oder Trendlinien aus dem Indikator zu übernehmen.

- Klicken Sie mit der rechten Maustaste auf ein Diagramm und suchen Sie LIST OF OBJECTS(kopieren und in Expert Advisor einfügen)

Foto von

 
Hallo an alle!
Ich bitte um Hilfe, ich habe mir schon das Hirn zermartert, ich kann nicht finden, wie man das Folgende implementiert.
Wenn Sie einen neuen Balken öffnen, führen Sie eine Berechnung durch.
Wenn Sie wieder einen neuen Balken öffnen, führen Sie die Berechnung und alle Aktionen aus.
Ich kann es in MQL5 nicht finden
Bitte helfen Sie!!!
 
m-r LSV:
Hallo an alle!
Ich bitte um Hilfe, ich habe mir schon das Hirn zermartert, ich kann nicht finden, wie man das Folgende implementiert.
Wenn Sie einen neuen Balken öffnen, führen Sie eine Berechnung durch.
Wenn Sie wieder einen neuen Balken öffnen, führen Sie die Berechnung und alle Aktionen aus.
Ich kann es in MQL5 nicht finden
Bitte helfen Sie!!!
Wenn es sich um einen Indikator handelt, gibt es rates_total und prev_calculated. Wenn es für einen EA ist, dann das gleiche wie in mql4...
 
Alexey Viktorov:
Wenn es sich um einen Indikator handelt, gibt es rates_total und prev_calculated. Wenn es für Expert Advisor ist, ist es das gleiche wie in mql4...

Kann ich bitte ein kurzes Stück Code haben, ich bin ein Neuling und mein Kopf kocht schon. Verwirrt.

 
Alexey Viktorov:
Wenn es sich um einen Indikator handelt, gibt es rates_total und prev_calculated. Wenn es für einen EA ist, dann das gleiche wie in mql4...

Ja, es ist für den Indikator

 

Alexey Viktorov:
Если это для индикатора, то есть rates_total и prev_calculated. Если-же для советника, то так-же как и в mql4…


if(rates_total > prev_calculated)
 Print("Новый бар");

Verstehe ich das richtig?

 

Die Öffnung der Kerze wird um 9-12 Sekunden verzögert.
Können Sie mir bitte sagen, ob dies die erste Zecke ist?

Es ist einfach extrem wichtig für mich, Berechnungen anzustellen und alle Aktionen beim ersten Tick einer neuen Kerze durchzuführen.

2021.06.02 16:42:09.522 Test (Volatility 10 Index,M1)      Новый бар
2021.06.02 16:43:09.621 Test (Volatility 10 Index,M1)      Новый бар
2021.06.02 16:44:09.552 Test (Volatility 10 Index,M1)      Новый бар

 
m-r LSV:

Verstehe ich das richtig?

datetime fin=0, last=0;

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[])
   {
   fin=iTime(symbol,frame,0);
   if(last==fin) return(rates_total);
   last=fin;
Grund der Beschwerde: