Cualquier pregunta de los recién llegados sobre MQL4 y MQL5, ayuda y discusión sobre algoritmos y códigos - página 1287

 

¡Hola! 2020.10.28_05:19:00 GMT+3. He traducido el indicador LeManTrend_Indicator.mq5 a la cuarta versión .mq4 . El indicador aparece en el gráfico, pero cuando intento cambiar GBPUSD,H1 a M5 timeframe, MetaTrader4 se cuelga, la CPU está sobrecargada. Tengo que cerrar MetaTrader4 y abrirlo de nuevo. No se congela cuando quito LeManTrend_Indicator.ex4 del gráfico. No entiendo qué es lo que falla en el código del indicador. ¿Quién puede darme una pista? ¿Cómo solucionarlo?

Y LeMan_BrainTrend1Sig.mq5 convertido a la cuarta versión, está en la lista de indicadores, pero no aparece nada en el gráfico. Cómo reescribir el código de este indicador para que funcione correctamente, no lo sé. Ya he escrito antes sólo sobre Asesores Expertos. Cómo comprobarlos enel probador de estrategias- lo sé. Y cuando escribo Print() de las variables en el código, queda claro lo que está mal. No sé cómo comprobar los indicadores. He escrito Print() en el código, no se guarda en ningún registro. ¿Alguien me puede aconsejar qué hacer con los indicadores para que funcionen y no ocupen espacio en el disco duro? Espero tener noticias suyas. 05:44 GMT+3.

Sí, voy a publicar los códigos de los indicadores ahora. Una cosa más. ¿Por qué he convertido los indicadores de .mq5 a .mq4? Porque mi broker tiene cuentas en rublos sólo en MetaTrader4. Y los indicadores están escritos en quinta versión. Y necesito indicadores para escribir un Asesor Experto rentable para MetaTrader4. Eso es todo. 05:53 GMT+3.

Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
  • www.metatrader5.com
Тестер стратегий позволяет тестировать и оптимизировать торговые стратегии (советники) перед началом использования их в реальной торговле. При тестировании советника происходит его однократная прогонка с начальными параметрами на исторических данных. При оптимизации торговая стратегия прогоняется несколько раз с различным набором параметров...
 
Николай Никитюк:

¡Hola! 2020.10.28_05:19:00 GMT+3. He traducido el indicador LeManTrend_Indicator.mq5 a la cuarta versión .mq4 . El indicador aparece en el gráfico, pero cuando intento cambiar GBPUSD,H1 a M5 timeframe, MetaTrader4 se cuelga, la CPU está sobrecargada. Tengo que cerrar MetaTrader4 y abrirlo de nuevo. No se congela cuando quito LeManTrend_Indicator.ex4 del gráfico. No entiendo qué es lo que falla en el código del indicador. ¿Quién puede darme una pista? ¿Cómo solucionarlo?

Y LeMan_BrainTrend1Sig.mq5 convertido a la cuarta versión, está en la lista de indicadores, pero no aparece nada en el gráfico. Cómo reescribir el código de este indicador para que funcione correctamente, no lo sé. Ya he escrito antes sólo sobre Asesores Expertos. Cómo comprobarlos enel probador de estrategias- lo sé. Y cuando escribo Print() de las variables en el código, queda claro lo que está mal. No sé cómo comprobar los indicadores. He escrito Print() en el código, no se guarda en ningún registro. ¿Alguien me puede aconsejar qué hacer con los indicadores para que funcionen y no ocupen espacio en el disco duro? Espero tener noticias suyas. 05:44 GMT+3.

Sí, voy a publicar los códigos de los indicadores ahora. Una cosa más. ¿Por qué he convertido los indicadores de .mq5 a .mq4? Porque mi broker tiene cuentas en rublos sólo en MetaTrader4. Y los indicadores están escritos en quinta versión. Y necesito indicadores para escribir un Asesor Experto rentable para MetaTrader4. Eso es todo. 05:53 GMT+3.

LeManTrend_Indicator.mq5- el propio indicador aquíhttps://www.mql5.com/ru/code/27570

también funciona en el 4 - pero hay que quitar la repetición (string ) antes de (err_text)

      string err_text=(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")?
                      "Параметр \"Midle\" меньше 1!":
                      "Parameter \"Midle\" is less than 1!";

se vería así

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- check "MA averaging period" parameter
   if(PeriodEMA<1)
     {
      string err_text=(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")?
                      "Параметр \"MA averaging period\" меньше 1!":
                      "Parameter \"MA averaging period\" is less than 1!";
      //--- when testing, we will only output to the log about incorrect input parameters
      if(MQLInfoInteger(MQL_TESTER))
        {
         Print(__FILE__," ",__FUNCTION__,", ERROR: ",err_text);
         return(INIT_FAILED);
        }
      else // if the Expert Advisor is run on the chart, tell the user about the error
        {
         Alert(__FILE__," ",__FUNCTION__,", ERROR: ",err_text);
         return(INIT_PARAMETERS_INCORRECT);
        }
     }
//--- check "Min" parameter
   if(Min<1)
     {
      err_text=(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")?
               "Параметр \"Min\" меньше 1!":
               "Parameter \"Min\" is less than 1!";
      //--- when testing, we will only output to the log about incorrect input parameters
LeManTrend Indicator
LeManTrend Indicator
  • www.mql5.com
Индикатор на основе анализа максимальных и минимальных цен. Сигналы индикатора возникают в месте пересечения линий 'BUY' и 'SELL':
 
SanAlex:

LeManTrend_Indicator.mq5- el propio indicador aquíhttps://www.mql5.com/ru/code/27570

también funciona en el 4 - pero hay que quitar la repetición (string ) antes de (err_text)

debería ser así

cadena

 
Николай Никитюк:

BrainTrend1Sig para 4 aquí -https://www.mql5.com/ru/code/8772

Este debe contener el LeManTrend_Indicator.mq4 ya corregido para 4

BrainTrend1Sig
BrainTrend1Sig
  • www.mql5.com
Индикатор BrainTrend1Sig.
 
SanAlex:

BrainTrend1Sig para 4 aquí -https://www.mql5.com/ru/code/8772

Aquí tienes que añadir LeManTrend_Indicator.mq4, ya arreglado para 4

hay un error - necesitas borrar esta línea ( double const = 0; )

y todo funcionará

    doble const = 0;

doble const = 0; 2.PNG


 
Nikolai Semko:

Eres un comediante.

¿Con quién estaba hablando?



¿A qué se debe esta situación? El mismo índice de barras. Y parece que sólo ocurre en la primera ejecución de un símbolo. O bien profundizar en la historia. Pensaba que el código de arriba sólo comprobaba las barras...

 
Николай Никитюк:


Aquí hay un buen indicadorhttps://www.mql5.com/ru/code/28364

¡¡¡¡¡¡¡Todo lo que necesita puede ser incorporado en él !!!!!!!

//+------------------------------------------------------------------+
//|                                                      Phoenix.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//--- setting the indicator name
#property description "Phoenix"
//--- set the strict mode of compilation
#property strict
//--- specify where to draw the indicator
#property indicator_chart_window
//--- specify the number of buffers
#property indicator_buffers 2
//--- setting the color of the indicator rendering
#property indicator_color1 clrGreenYellow
#property indicator_color2 clrRed
//--- we define the input parameters

//--- specify arrays of indicator buffers
double arrow_01[];
double arrow_02[];
//*********************************************//
bool flag_buy   = false;
bool flag_sell  = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   string short_name;
//--- we specify two additional buffers for calculations
   IndicatorBuffers(2);
   SetIndexBuffer(0,arrow_01);
   SetIndexBuffer(1,arrow_02);
//--- setting the indicator to be drawn as a line
   SetIndexStyle(0,DRAW_ARROW,EMPTY,2,clrGreenYellow);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,arrow_01);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,2,clrRed);
   SetIndexArrow(1,234);
   SetIndexBuffer(1,arrow_02);
//--- setting a name in the DataWindow window and a label
   short_name="Phoenix";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- if there are no errors,initialization is completed successfully
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                            Phoenix                               |
//+------------------------------------------------------------------+
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[])
  {
   for(int shift=rates_total; shift>=0; shift--)
     {
      //--- to simplify the coding and speed up access data are put into internal variables
      double MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,shift);
      double SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,shift);
        {
         if(flag_buy==false)
            //--- check for long position (BUY) possibility
            if(MacdCurrent>SignalCurrent)
              {
               arrow_01[shift]=Low[shift];
               flag_buy=true;
               flag_sell=false;
              }
         if(flag_sell==false)
            //--- check for short position (SELL) possibility
            if(MacdCurrent<SignalCurrent)
              {
               arrow_02[shift]=High[shift];
               flag_buy=false;
               flag_sell=true;
              }
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
Phoenix
Phoenix
  • www.mql5.com
В стрелочном индикаторе Phoenix используется комбинация трех индикаторов: Moving Average, Bolinger Bands и Momentum в сочетании с двумя мощными формулами, основанными на поведении цены текущего графика. В индикаторе Phoenix также реализована система звуковых и текстовых алертов, а также отправка...
Archivos adjuntos:
EURUSDM30.png  35 kb
 

¡Buenas tardes!

Por favor, ayúdenme con la siguiente tarea:

Necesito ejecutar un script (Python) desde MQL4 Expert Advisor. Estoy tratando de hacerlo usando ShellExecuteW() de la siguiente manera:

#import "shell32.dll"
string ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
#include <WinUser32.mqh>

void OnStart()
  {
ShellExecuteW(NULL, NULL, "C:\\Users\\yansa\\Desktop\\test_script.py", NULL, NULL, 1);
  }

Obtengo un error de acceso al archivo. El script se ejecuta pero el código no va más allá.


Estaré encantado si puedes compartir la función para ejecutar el script.

Otra pregunta: ¿cómo puedo comprobar la ejecución del script?

 
Николай Никитюк:

¡Hola! 2020.10.28_05:19:00 GMT+3. He traducido el indicador LeManTrend_Indicator.mq5 a la cuarta versión .mq4 .

Este no encaja

https://www.mql5.com/ru/code/9096

LeManTrend
LeManTrend
  • www.mql5.com
Индикатор определяет положение тренда на основе текущей цены и максимальных и минимальных цен за три периода.
 
MakarFX:

Y este no encaja.

https://www.mql5.com/ru/code/9096

Este parece ser mejor.

//+------------------------------------------------------------------+
//|                                                      Phoenix.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//--- setting the indicator name
#property description "Phoenix"
//--- set the strict mode of compilation
#property strict
//--- specify where to draw the indicator
#property indicator_chart_window
//--- specify the number of buffers
#property indicator_buffers 2
//--- setting the color of the indicator rendering
#property indicator_color1 clrGreenYellow
#property indicator_color2 clrRed
//--- we define the input parameters

//--- specify arrays of indicator buffers
double arrow_01[];
double arrow_02[];
//*********************************************//
bool flag_buy   = false;
bool flag_sell  = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   string short_name;
//--- we specify two additional buffers for calculations
   IndicatorBuffers(2);
   SetIndexBuffer(0,arrow_01);
   SetIndexBuffer(1,arrow_02);
//--- setting the indicator to be drawn as a line
   SetIndexStyle(0,DRAW_ARROW,EMPTY,2,clrGreenYellow);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,arrow_01);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,2,clrRed);
   SetIndexArrow(1,234);
   SetIndexBuffer(1,arrow_02);
//--- setting a name in the DataWindow window and a label
   short_name="Phoenix";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- if there are no errors,initialization is completed successfully
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                            Phoenix                               |
//+------------------------------------------------------------------+
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[])
  {
   for(int shift=rates_total; shift>=0; shift--)
     {
      //--- to simplify the coding and speed up access data are put into internal variables
      double MacdCurrent=iCustom(NULL,0,"LeManTrend",13,21,34,3,MODE_MAIN,shift);
      double SignalCurrent=iCustom(NULL,0,"LeManTrend",13,21,34,3,MODE_SIGNAL,shift);
        {
         if(flag_buy==false)
            //--- check for long position (BUY) possibility
            if(MacdCurrent>SignalCurrent)
              {
               arrow_01[shift]=Low[shift];
               flag_buy=true;
               flag_sell=false;
              }
         if(flag_sell==false)
            //--- check for short position (SELL) possibility
            if(MacdCurrent<SignalCurrent)
              {
               arrow_02[shift]=High[shift];
               flag_buy=false;
               flag_sell=true;
              }
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
Archivos adjuntos:
Razón de la queja: