Questions des débutants MQL5 MT5 MetaTrader 5 - page 630

 
Alexey Volchanskiy:

1. Regardez maintenant la résolution et l'échelle de l'écran. Je ne sais pas comment faire ça sur 8.1, je suis moi-même sur 10 pour le moment. Vous avez clairement déplacé tous les contrôles. C'est typique lorsque vous écrivez un programme pour une échelle standard, et que l'utilisateur le règle généralement sur une échelle plus grande. Vous n'avez pas un ordinateur portable avec un petit écran, n'est-ce pas ? Ils font généralement un zoom avant car il est difficile de voir les petits éléments.

C'est comme ça que ça se passe sur la 10.

2. Vous devez le régler sur la norme - 100%.

1. J'ai un ordinateur portable avec un "grand" écran... :-)

2. C'est ce que j'ai fait.

Merci pour l'aide...

 
Roman Shiredchenko:

1. J'ai un ordinateur portable avec un "grand" écran... :-)

2. C'est ce que j'ai fait.

Merci pour l'aide...

J'ai également pensé à la résolution, en lisant la question - j'ai été devancé par la réponse.

Vous vous comprenez - il est irréaliste d'écrire une plateforme pour tous les écrans de n'importe quel appareil)

 
new-rena:

Je pensais aussi à la résolution, quand j'ai lu la question, vous m'avez devancé.

Vous savez, il est impossible d'écrire une plateforme pour tous les écrans de n'importe quel appareil).

Sens... :-) Je ne suis pas venu ici depuis un moment... Les affaires... :-)

Les mêmes vieux visages. Ce qui est bon !

Bien que vous ne puissiez pas voir beaucoup d'entre eux...

 
Je ne me souviens pas et ne trouve pas dans la documentation comment séparer la ligne de commentaire des paramètres de l'EA, dans la fenêtre appelée par F7.
 
new-rena:

Je pensais aussi à la résolution, mais quand j'ai lu la question, la réponse m'a devancé.

Vous vous comprenez - il est irréaliste d'écrire une plateforme pour tous les écrans de n'importe quel appareil)

Oui, je me souviens que lorsque nous avons écrit pour Windows et que nous avons commencé à livrer des écrans larges aux clients, nous avons eu beaucoup de mal à redessiner les interfaces graphiques.
 
Vladimir Tkach:
Je ne me souviens pas et ne trouve pas dans la documentation comment séparer la ligne de commentaire des paramètres de l'EA, dans la fenêtre appelée par F7.

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

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;
        }
   }
Comment le faire comme dans Excel ?)

Tout fonctionne très bien !!!! Ce n'était pas l'algorithme. Le problème est résolu.
 

Décidé ici par un quadruplet :

Il y a un code indicateur. Il compte et dessine les lignes d' ascension et d'enchère + compte la vitesse moyenne X des ticks frais Num_Aver_of_Ticks reçus en Sec_at_Num_Aver_of_Ticks secondes. X = Num_Aver_of_Ticks / (time_s - ExtMapBuffer3[Num_Aver_of_Ticks]) ;

Comment puis-je lire la valeur de cette variable X (voir la fin de la fonction de démarrage) dans l'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:

Décidé ici par un quadruplet :

Il y a un code indicateur. Il compte et dessine les lignes d' ascension et d'enchère + compte le taux moyen X de ticks frais Num_Aver_of_Ticks reçus par Sec_at_Num_Aver_of_Ticks secondes. X = Num_Aver_of_Ticks / (time_s - ExtMapBuffer3[Num_Aver_of_Ticks]) ;

Comment puis-je lire la valeur de cette variable X (voir la fin de la fonction de démarrage) dans l'EA ?

Il est difficile de regarder le code sur la tablette, mais la réponse est d'écrire la valeur de X dans le tampon.
 
Artyom Trishkin:
Il est difficile de regarder le code sur la tablette, mais la réponse est inévitable - écrire la valeur Х dans le tampon.

Merci. Artyom. Il en va de même pour moi... :-)


J'ai écrit cet acte il y a longtemps, et j'ai utilisé le code de Rosha de kodobase comme base.

Raison: