Preguntas de los principiantes MQL5 MT5 MetaTrader 5 - página 1307

 
¡Hola!

He transferido un indicador de MQL4 a MQL5 y no puedo entender por qué no funciona:

void GetDellName(string name_n = " ")
  {
   string vName;
   for(int i=ObjectsTotal()-1; i>=0; i--)
     {
      vName = ObjectName(i);
      if(StringFind(vName,name_n) !=-1)
         ObjectDelete(vName);
     }
  }

MetaEditor en MQL5 se queja:


'ObjectsTotal' - recuento de parámetros erróneo

'ObjectName' - recuento de parámetros erróneo

ObjectDelete' - recuento de parámetros erróneo

Todo funciona en MQL4 sin errores.

Por favor, ayúdenme a entender

 
Sprut 185:
¡Hola!

He transferido un indicador de MQL4 a MQL5 y no puedo entender por qué no funciona:


MetaEditor en MQL5 se queja:


'ObjectsTotal' - recuento de parámetros erróneo

'ObjectName' - recuento de parámetros erróneo

ObjectDelete' - recuento de parámetros erróneo

Todo funciona en MQL4 sin errores.

Por favor, ayúdenme a entender

1. Por favor, pegue el código correctamente. Cuando edite su mensaje, pulse el botón Código y pegue el código en la ventana emergente que aparece (edité su mensaje por primera vez).

2. Lee atentamente la ayuda. Por ejemploObjectsTotal

int  ObjectsTotal(
   long  chart_id,           // идентификатор графика
   int   sub_window=-1,      // индекс окна
   int   type=-1             // тип объекта     
   );
Документация по MQL5: Графические объекты / ObjectsTotal
Документация по MQL5: Графические объекты / ObjectsTotal
  • www.mql5.com
ObjectsTotal - Графические объекты - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Sprut 185:

¿Qué te parece esto? - elimina todas las líneas horizontales y de tendencia

//+------------------------------------------------------------------+
//|                                                  GetDellName.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"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   GetDellName();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetDellName(void)
  {
   int nHLines=ObjectsTotal(0,-1,OBJ_HLINE),
       nTrendLines=ObjectsTotal(0,-1,OBJ_TREND),i;
   string objName;
   for(i=0; i<nHLines; i++)
     {
      objName=ObjectName(0,i,0,OBJ_HLINE);
      ObjectDelete(0,objName);
     }
   for(i=0; i<nTrendLines; i++)
     {
      objName=ObjectName(0,i,0,OBJ_TREND);
      ObjectDelete(0,objName);
     }
   return(GetDellName());
  }
//+------------------------------------------------------------------+

-----------------------------------------------------\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\------------------------------------------------------

o elimina todos los objetos así

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetDellName(void)
  {
   int ObjectsName=ObjectsTotal(0,-1,-1),i;
   string objName;
   for(i=0; i<ObjectsName; i++)
     {
      objName=ObjectName(0,i,0,-1);
      ObjectDelete(0,objName);
     }
   return(GetDellName());
  }
//+------------------------------------------------------------------+

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

o así, como dice Alexey Viktorov.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetDellName(void)
  {
   ObjectsDeleteAll(0,-1,-1);
//--- "clear" comment
   Comment("");
   return(false);
  }
//+------------------------------------------------------------------+
 
SanAlex:

¿Qué te parece esto? - elimina todas las líneas horizontales y de tendencia

¿Por qué hay un ciclo?

int  ObjectsDeleteAll(
   long  chart_id,            // идентификатор графика
   int   sub_window=-1,       // индекс окна
   int   type=-1              // тип объекта для удаления
   );
 
Alexey Viktorov:

¿Por qué hay un ciclo aquí?

¿¡Honestamente!? - ¡No tengo ni idea! - Sólo algo con lo que ocuparme por la mañana.

 
SanAlex:

¿Qué te parece esto? - elimina todas las líneas horizontales y de tendencia

-----------------------------------------------------\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\------------------------------------------------------

o elimina todos los objetos así

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

o como dice Alexey Viktorov.

también puede ser así

//+------------------------------------------------------------------+
//|                                                  GetDellName.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"

string   m_name[]= {"1 имя объекта","2 имя объекта","3 имя объекта","4 имя объекта","5 имя объекта","6 имя объекта"};
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   GetDellName();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetDellName(void)
  {
   for(int i=0; i<ArraySize(m_name); i++)
     {
      ObjectDelete(0,m_name[i]);
     }
   return(false);
  }
//+------------------------------------------------------------------+

o así

//+------------------------------------------------------------------+
//|                                                     FILTER_1.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 InpName_1 = "HorizontalTrend Line_1"; // FILTER_1
sinput string InpName   = "HorizontalTrend Line";   // FILTER
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit(void)
  {
//---
   EventSetMillisecondTimer(1);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   EventKillTimer();
   GetDellName("");
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick(void)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTimer(void)
  {
   MqlRates rates[],rates_1[];
   int start_pos=0,count=1;
   if(CopyRates(Symbol(),Period(),start_pos,count,rates)!=count)
     {
      return;
     }
   if(CopyRates(Symbol(),Period(),start_pos,count,rates_1)!=count)
     {
      return;
     }
//---
   double price_line=0.0;
   if(ObjectFind(0,InpName)>=0)
     {
      long object_type=ObjectGetInteger(0,InpName,OBJPROP_TYPE);
      if(object_type==OBJ_HLINE)
         price_line=ObjectGetDouble(0,InpName,OBJPROP_PRICE);
      else
         if(object_type==OBJ_TREND)
            price_line=ObjectGetValueByTime(0,InpName,rates[0].time,0);
      if(price_line>0.0)
        {
         if(rates[0].open<price_line)
           {
            Alert("1");
            GetDellName(InpName);
           }
        }
     }
//---
   double price_line_1=0.0;
   if(ObjectFind(0,InpName_1)>=0)
     {
      long object_type_1=ObjectGetInteger(0,InpName_1,OBJPROP_TYPE);
      if(object_type_1==OBJ_HLINE)
         price_line_1=ObjectGetDouble(0,InpName_1,OBJPROP_PRICE);
      else
         if(object_type_1==OBJ_TREND)
            price_line_1=ObjectGetValueByTime(0,InpName_1,rates_1[0].time,0);
      if(price_line_1>0.0)
        {
         if(rates_1[0].open>price_line_1)
           {
            Alert("2");
            GetDellName(InpName_1);
           }
        }
     }
//---
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetDellName(string objName)
  {
   int nHLines=ObjectsTotal(0,-1,OBJ_HLINE),
       nTrendLines=ObjectsTotal(0,-1,OBJ_TREND),i;
   for(i=0; i<nHLines; i++)
     {
      objName=ObjectName(0,i,0,OBJ_HLINE);
      ObjectDelete(0,objName);
     }
   for(i=0; i<nTrendLines; i++)
     {
      objName=ObjectName(0,i,0,OBJ_TREND);
      ObjectDelete(0,objName);
     }
   return(false);
  }
//+------------------------------------------------------------------+
 

Necesito ayuda para configurar MT5 .

1. Problema En MT5 he cambiado a una cuenta DEMO pero el botón para colocar órdenes no está activo, en la parte inferior se puede ver que no hay conexión con el servidor y los tickers de los contratos para 2019 y 2020 se cargan desde su base de datos en la lista, pero no hay contratos reales.

 
gorod258:
Necesito ayuda para configurar MT5 desde cero.

https://www.metatrader5.com/ru/terminal/help/startworking/settings

Настройки платформы - Начало работы - Справка по MetaTrader 5
Настройки платформы - Начало работы - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая платформа обладает множеством настроек, что позволяет организовать работу в ней так, как это удобно именно вам. Выполните команду...
 

Lo he preconfigurado, pero por alguna razón parte de la función no funciona .

1. Problema En MT5 he cambiado a una cuenta DEMO pero el botón para colocar órdenes no está activo, se puede ver en la parte inferior que no hay conexión con el servidor y los tickers de los contratos para 2019 y 2020 se cargan desde su base de datos en la lista pero no hay contratos reales.

¿Podría ayudar?

 
SanAlex:

¿¡Honestamente!? - ¡No tengo ni idea! - Sólo algo que hacer por la mañana.

Bueno, lo borrará de todos modos, sin condiciones).

Razón de la queja: