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

 
Alexey Volchanskiy:

1. ahora mira la resolución y la escala de la pantalla. No sé cómo hacer esto en 8.1, yo mismo estoy en 10 en este momento. Claramente tienes todos los controles desplazados. Es típico cuando se escribe un programa para una escala estándar, y el usuario suele ajustarlo a una escala mayor. No tienes un portátil con una pantalla pequeña, ¿verdad? Suelen hacer zoom porque es difícil ver los elementos pequeños.

Así es como está configurado el 10.

2. Tienes que ponerlo en estándar - 100%

1. Tengo un portátil con una pantalla "grande"... :-)

2. Así que lo hice.

Gracias por la ayuda...

 
Roman Shiredchenko:

1. Tengo un portátil con una pantalla "grande"... :-)

2. Así que lo hice.

Gracias por la ayuda...

También he pensado en la resolución, mientras leía la pregunta, y me he adelantado a la respuesta.

Tú mismo lo entiendes: es poco realista escribir una plataforma para todas las pantallas de cualquier dispositivo)

 
new-rena:

Yo también estaba pensando en la resolución, cuando he leído la pregunta, te has adelantado.

Es imposible escribir una plataforma para todas las pantallas de cualquier dispositivo)

Sens... :-) Hace tiempo que no vengo por aquí... Negocios... :-)

Las mismas caras de siempre. ¡Qué bueno!

Aunque no se ven muchos...

 
No recuerdo y no encuentro en la documentación cómo dividir la línea de comentario de los parámetros del EA, en la ventana llamada por F7.
 
new-rena:

Yo también estaba pensando en la resolución, pero al leer la pregunta se me adelantó la respuesta.

Tú mismo lo entiendes: es poco realista escribir una plataforma para todas las pantallas de cualquier dispositivo)

Sí, recuerdo que cuando escribimos para Windows y empezamos a entregar pantallas panorámicas a los clientes, tuvimos muchos problemas con el rediseño de la interfaz gráfica de usuario
 
Vladimir Tkach:
No recuerdo y no encuentro en la documentación cómo dividir la línea de comentarios de los parámetros del EA, en la ventana llamada por F7.

sinput string separator = "";   //в комментарий записать пустой символ "Alt+(Num)255"
 
¡Hola!
// Существует алгоритм сортировки "ПУЗЫРЬКОМ" по убыванию

void bubble_sort(int &a[], int length)
   {
    for(int i=0; i<length-1; i++)
        {
         bool swapped = false;
         for(int j=0; j<length-i-1; j++)
             {
              if(a[j] < a[j+1])
                  {
                   int b = a[j];
                   a[j] = a[j+1];
                   a[j+1] = b;
                   swapped = true;
                  }
             }
         if(!swapped)
              break;
        }
   }

// Есть массив D[][2]. Подскажите пожалуйста, как правильно организовать сортировку массива D[][2] 
// сначала по параметру с индексом "0", а потом по параметру с индексом "1"
// Такой вариант не проходит (сортирует не правильно):

double D[][2];                                   // Исходный динамический массив
double S[2];                                     // Временный статический массив

//        Исходный     Сортировка по индексу "0"    Сортировка по индексу "1"
//          7  4                  9  5                         9  8
//          3  9                  9  8                         9  5
//          9  5                  7  4                         7  6                              
//          9  8                  7  6                         7  4
//          7  6                  3  9                         3  9
//         ......

int    R=ArrayRange(D, 0);
       Fun();

void Fun()
   {
    int n=0;                                     // Техническая переменная
    int cur_0=0;                                 // Значение массива D[j]  [0] в строке с индексом "j"
    int fol_0=0;                                 // Значение массива D[j+1][0] в строке с индексом "j+1" 
    int cur_1=0;                                 // Значение массива D[j]  [1] в строке с индексом "j"
    int fol_1=0;                                 // Значение массива D[j+1][1] в строке с индексом "j+1" 

    for(int i=0; i<R-1; i++)                     // Сортировка по индексу "0"
        {
         bool swapped = false;
         for(int j=0; j<R-i-1; j++)
             {
              cur_0=a[j]  [0];
              fol_0=a[j+1][0];
              if(cur_0 < fol_0)
                  {
                   for(n=0; n<2; n++)
                        S[n]=D[j][n];            // Значения из строки [j] во временный массив 
                   for(n=0; n<2; n++)
                        D[j][n]=D[j+1][n];       // Значения из строки [j+1] в строку [j]
                   for(n=0; n<2; n++)
                        D[j+1][n]=S[n];          // Значения из временного массива в строку [j+1]
                   swapped = true;
                  }
             }
         if(!swapped)
              break;
        }

    for(i=0; i<R-1; i++)                         // Сортировка по индексу "1"
        {
         swapped = false;
         for(j=0; j<R-i-1; j++)
             {
              cur_0=a[j]  [0];
              fol_0=a[j+1][0];
              cur_1=a[j]  [1];
              fol_1=a[j+1][1];
              if( (cur_0 == fol_0) &&            // При равенстве значений по индексу "0"
                  (cur_1 <  fol_1) )
                  {
                   for(n=0; n<2; n++)
                        S[n]=D[j][n];            // Значения из строки [j] во временный массив 
                   for(n=0; n<2; n++)
                        D[j][n]=D[j+1][n];       // Значения из строки [j+1] в строку [j]
                   for(n=0; n<2; n++)
                        D[j+1][n]=S[n];          // Значения из временного массива в строку [j+1]
                   swapped = true;
                  }
             }
         if(!swapped)
              break;
        }
   }
Cómo hacerlo como en Excel ))

¡¡¡¡Todo funciona muy bien!!!! No era el algoritmo. La cuestión está resuelta.
 

Decidido aquí por el cuatripartito:

hay un código indicador. Cuenta y dibuja las líneas de ascenso y oferta + cuenta la tasa media X de ticks frescos Num_Aver_of_Ticks recibidos por Sec_at_Num_Aver_of_Ticks segundos. X = Num_Aver_of_Ticks / (time_s - ExtMapBuffer3[Num_Aver_of_Ticks]);

¿Cómo puedo leer el valor de esta variable X (véase el final de la función de inicio) en el EA?

//+------------------------------------------------------------------
//
//
//
//
//+------------------------------------------------------------------
#property copyright "ROMANBEST"
#property link      "rshiredchenko@mail.ru"

#property indicator_separate_window
#property indicator_buffers 2
#property  indicator_color1 clrLimeGreen
#property  indicator_color2 clrBlue           // Цвет второй линии
//#property indicator_color3 clrGray         // Цвет третьей линии - гистограммы
//---- buffers
extern int MaxDrawTicks=100;
extern int Num_Aver_of_Ticks=15;
//--- Создаём динамические массивы
double ExtMapBuffer1[];                      // Индикаторный массив значений цен Bid
double ExtMapBuffer2[];                      // Индикаторный массив значений цен Ask 
              // Кол-во тиков для среднего Num_Aver_of_Ticks / кол-во секунд, за которое эти тики поступили 
 // При обращении к любому члену массива по индексу (допустим i) нужно убедиться что i>=0 и i<ArraySize(High) 
double ExtMapBuffer3[];                      // Массив значений времени в сек. с момента запуска индикатора 
int size;                                    // Вспомогательная переменная для массива
 // При обращении к любому члену массива по индексу (допустим i) нужно убедиться что i>=0 и i<ArraySize(High) 

                                  
int myBars;
int i;
int delimeterCounter;
int _start,tickCounter;
double Sec_at_Num_Aver_of_Ticks; // кол-во секунд, за которое  поступило среднее количество тиков для расчёта 
                                 // (Num_Aver_of_Ticks)
  
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0, ExtMapBuffer1);           // Назначение массива буферу
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);  // Стиль линии    
   SetIndexEmptyValue(0,0.0);
   
   SetIndexBuffer(1, ExtMapBuffer2);           // Назначение массива буферу
   SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,2);  // Стиль линии    
   SetIndexEmptyValue(1,0.0); 
 
   
    
//--- устанавливаем размер динамического массива
   if(ArrayResize(ExtMapBuffer3,MaxDrawTicks)<0) {Print(" Ошибка в изменении размера массива времени поступления тиков "); return(false);}
//--- установим индексацию для буфера как в таймсерии для динамического массива
    // ArraySetAsSeries(ExtMapBuffer3,true);
    
//---   Возвращает количество элементов указанного массива. 
   size=ArraySize(ExtMapBuffer3);
   if (size>0) Print("Размер массива: ",size);
   else Print("Ошибка. Массив пустой ",size);     
                                                          // for(int i=0;i<=100;i++) Print(" ExtMapBuffer3[i] = ", ExtMapBuffer3[i]);   
   //--- заполняем начальные 50 элементов значением 4
 //  ArrayFill(ExtMapBuffer3,0,50,4);
//--- заполняем 50 элементов (начиная с 50-го) значением 8
 //   ArrayFill(ExtMapBuffer3,50,50,8);
//--- выводим значения всех элементов
 //  for(int i=0;i<ArraySize(ExtMapBuffer3);i++) Print(" i =  ", i, " ExtMapBuffer3 =  ", ExtMapBuffer3[i]);                      

//   ------------
   
   Print("Обнуляем тики и время их поступления");
   for (i=Bars-1;i>=0;i--) { ExtMapBuffer1[i]=0.0; ExtMapBuffer2[i]=0.0; ExtMapBuffer3[i]=0.0;} 
  
   //--- запомним начальное значение для подсчёта секунд c момента старта системы
   _start = GetTickCount();   
//----
   return(0);
  }
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| сдвинем массив                                                   |
//+------------------------------------------------------------------+
void SetDelimeter()
  {
//----
   string delimeterDate=TimeToStr(Time[0]);
   if (myBars!=0)
      {
      Print("Ставим разделитель");      
      int handle=WindowFind("Ticks");
      if(!ObjectCreate(delimeterDate,OBJ_VLINE,handle,Time[0],0))
         {
         Print("Неудачная попытка создания разделителя в окне ",
         handle," по времени ",TimeToStr(CurTime()));
         Print("Ошибка №",GetLastError(),", имя разделителя ",delimeterDate);
         }
      else 
         {
         ObjectSet(delimeterDate,OBJPROP_COLOR,DarkGreen);
         ObjectSet(delimeterDate,OBJPROP_STYLE,STYLE_DASHDOT);
         ObjectsRedraw();
         }
      }
//----   
  }
//+------------------------------------------------------------------+
//| сдвинем массив                                                   |
//+------------------------------------------------------------------+
void ShiftArray()
  {
//----
   int V_lines;
   string delimeterName;
   datetime firstTime;
   int BarFirstTime;
   
   if (tickCounter>2*MaxDrawTicks)
      {
      for (i=tickCounter;i>=MaxDrawTicks;i--) { ExtMapBuffer1[i]=0.0; ExtMapBuffer2[i]=0.0; ExtMapBuffer3[i]=0.0; }
      tickCounter=MaxDrawTicks;
      }
   for(int cnt=tickCounter;cnt>0;cnt--)
      {
      ExtMapBuffer1[cnt]=ExtMapBuffer1[cnt-1];
      ExtMapBuffer2[cnt]=ExtMapBuffer2[cnt-1];
      ExtMapBuffer3[cnt]=ExtMapBuffer3[cnt-1];
      }
   V_lines=ObjectsTotal();
   for (int z=0;z<V_lines;z++)
      {
      delimeterName=ObjectName(z); 
      if (ObjectFind(delimeterName)!=-1)
         {
         if (ObjectType(delimeterName)==OBJ_VLINE) 
            {
            firstTime=ObjectGet(delimeterName,OBJPROP_TIME1);
            BarFirstTime=iBarShift(NULL,0,firstTime);
            firstTime=Time[BarFirstTime+1];
            ObjectSet(delimeterName,OBJPROP_TIME1,firstTime); 
            }
         }       
      }
//----   
  }
//+------------------------------------------------------------------+
//| признак нового бара                                              |
//+------------------------------------------------------------------+
bool isNewBar()
  {
//----
   bool res=false;
   if (myBars!=Bars)
      {
      res=true;
      myBars=Bars;
      }   
//----
   return(res);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {   
  //--- выводим значения всех элементов
   // for(int i=0;i<ArraySize(ExtMapBuffer3);i++) Print(" i =  ", i, " ExtMapBuffer3 =  ", ExtMapBuffer3[i]);      
   //--- получим время в миллисекундах, прошедших с момента старта системы 
   uint time_ms=GetTickCount() - _start;
   //--- получим время в секундах, прошедших с момента старта системы 
   double time_s=time_ms/1000;
   double X;                      // вспомогательная переменная 
   
   int    counted_bars=IndicatorCounted();
//----
   if (isNewBar())
     {
      // установить разделитель
      //tickCounter++;
      SetDelimeter();
      ExtMapBuffer1[0]=Bid;  
      ExtMapBuffer2[0]=Ask; 
             //ExtMapBuffer3[0]= time_s;  
      //--- заполняем c tickCounter элементов значением time_s
     // ArrayFill(ExtMapBuffer3,tickCounter,1,time_s);  
     if (tickCounter >= 0 && tickCounter < ArraySize(ExtMapBuffer3) && tickCounter <= Num_Aver_of_Ticks)    
     {
      //--- заполняем начальный и последующие элементы значениями time_s
      if (tickCounter == 0) ArrayFill(ExtMapBuffer3,0,1,time_s);
      else                  ArrayFill(ExtMapBuffer3,tickCounter,1,time_s);
      //--- выводим значение элемента
       for( i=0;i<1;i++) Print(" tickCounter =  ", tickCounter, " ExtMapBuffer3 =  ", ExtMapBuffer3[tickCounter]);     
     }        
     }
   else
      
     {
      tickCounter++;
      ShiftArray();
      ExtMapBuffer1[0]=Bid; 
      ExtMapBuffer2[0]=Ask;  
      ExtMapBuffer3[0]= time_s;  
      // массив    // индекс начального элемента // количество элементов // значение, которым заполняется массив      
      //--- заполняем начальные (с нуля) tickCounter  элементов значением time_s
      //ArrayFill(ExtMapBuffer3,tickCounter,1,time_s);    
                                              // X = tickCounter/time_s;  
       if (tickCounter >= 0 && tickCounter < ArraySize(ExtMapBuffer3) && tickCounter <= Num_Aver_of_Ticks)    
          {
      //--- заполняем начальный и последующие элементы значениями time_s
            if (tickCounter == 0) ArrayFill(ExtMapBuffer3,0,1,time_s);
            else                  ArrayFill(ExtMapBuffer3,tickCounter,1,time_s);
      //--- выводим значение элемента
           for( i=0;i<1;i++) Print(" tickCounter =  ", tickCounter, " ExtMapBuffer3 =  ", ExtMapBuffer3[tickCounter]);     
          }                                                                         
     }
 /*    
    if (tickCounter > Num_Aver_of_Ticks) то ищем индекс массива с минимумом http://docs.mql4.com/ru/array/arrayminimum и заполняем его значением секунд 
    следующего тика...   Потом считаем разность между этим значением и следующим минимумом...
    Псле заполнения массива до ExtMapBuffer3[Num_Aver_of_Ticks]. Читать минимум, максимум. Переписываем минимум. Разница значений 
    ExtMapBuffer3[максимум] и ExtMapBuffer3[минимум] будет время в секундах поступления Num_Aver_of_Ticks.
    
*/    
      Sec_at_Num_Aver_of_Ticks =  time_s - ExtMapBuffer3[Num_Aver_of_Ticks];
      
      if (tickCounter >= Num_Aver_of_Ticks  && (time_s - ExtMapBuffer3[Num_Aver_of_Ticks])!=0) 
          X = Num_Aver_of_Ticks / (time_s - ExtMapBuffer3[Num_Aver_of_Ticks]);        
       
      
     if (time_s!=0) 
       Comment(
              "tickCounter = ", tickCounter, "\n",
              "secondCounter = ",    NormalizeDouble(time_s,Digits) , "\n",
              "ExtMapBuffer1[0] = ", NormalizeDouble(ExtMapBuffer1[0],Digits) , "\n",
              "ExtMapBuffer2[0] = ", NormalizeDouble(ExtMapBuffer2[0],Digits) , "\n",
              "ExtMapBuffer3[0] = ", NormalizeDouble(ExtMapBuffer3[0],Digits) , "\n",
              "Average speed for average quantity of tics = ", NormalizeDouble(X,2), " Num_Aver_of_Ticks/Sec_at_Num_Aver_of_Ticks ", "\n",
              "Num_Aver_of_Ticks =  ", Num_Aver_of_Ticks," Время в секундах поступления  Num_Aver_of_Ticks = ",Sec_at_Num_Aver_of_Ticks  , "\n",
              "Average speed since running = ", NormalizeDouble(tickCounter/time_s,Digits) , " All Tick/All Second ", "\n",
              
              
           "") ;    
                    
            
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Roman Shiredchenko:

Decidido aquí por el cuatripartito:

hay un código indicador. Cuenta y dibuja las líneas de ascenso y oferta + cuenta la tasa media X de ticks frescos Num_Aver_of_Ticks recibidos por Sec_at_Num_Aver_of_Ticks segundos. X = Num_Aver_of_Ticks / (time_s - ExtMapBuffer3[Num_Aver_of_Ticks]);

¿Cómo puedo leer el valor de esta variable X (ver final de la función de inicio) en el EA?

Es difícil mirar el código en la tableta, pero la respuesta es escribir el valor de X en el buffer.
 
Artyom Trishkin:
Es difícil mirar el código en la tableta, pero la respuesta es inevitable - escribir el valor Х en el buffer.

Gracias. Artyom. Lo mismo ocurre conmigo... :-)


Hace tiempo que escribí esta acusación, y utilicé el código de Rosha de kodobase como base.

Razón de la queja: