Errors, bugs, questions - page 2911

 
DMITRII PECHERITSA:
compile fail with ternary operator
compile fail with ternary operator ?


any suggestions?
why?
https://www.mql5.com/ru/docs/basis/operators/ternary
Read the docs)
 
DMITRII PECHERITSA:
compile fail with ternary operator
compile fail with ternary operator ?


any suggestions?
why?

Not =, but ==

 

Is there any way to randomly shuffle the numbers within a given range?

For example, there is a range from 0 to 9. Is it possible to shuffle them - 5863014297? Stir exactly, not get a random number from that range - rand is not suitable.

Документация по MQL5: Математические функции / MathRand
Документация по MQL5: Математические функции / MathRand
  • www.mql5.com
MathRand - Математические функции - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Aleksei Lesnikov:

Is there any way to randomly shuffle the numbers within a given range?

For example, there is a range from 0 to 9. Is it possible to shuffle them - 5863014297? Stir exactly, not get a random number from a given range - rand is not suitable.

Translate the number into a string, change the characters of the string with each other using some algorithm (you can think of it) - and then convert the number from the string back to double or int

 
Alexandr Sokolov:

convert this number to a string, change the characters of this string with each other using some algorithm (you can think of it), and then convert the number from the string back to double or int.

Thank you, this is an option!
And if the range is several thousand, or even tens of thousands of numbers?
 
Aleksei Lesnikov:
Thank you, that's an option!
What if the range is several thousand, or even tens of thousands of numbers?

a string is an array

make an array out of the required number

 
Hi!!! I don't understand it))) The order in the list of objects for some reason if you don't change the names of objects, then when selecting and processing objects through this cycle
 for(int i=0; i < Fibo_Koll; i++)
     {
      n=ObjectName(0,i,0,OBJ_FIBO);

order is maintained. But if you change the names with these functions

bool  F =ObjectSetString(0,n,OBJPROP_NAME,NameFiboUp[UP]);
bool  F =ObjectSetString(0,n,OBJPROP_NAME,NameFiboDown[Down]);

then the next object is selected randomly???

//+------------------------------------------------------------------+
//|                                                  Fibo_Massiv.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
// Expert initialization function
string NameFiboUp[15];                               // Объявление массива
string NameFiboDown[15];                               // Объявление массива   
string NameFibo[9];                               // Объявление массива   
                         

//+------------------------------------------------------------------+
int OnInit()
  {
//---
   NameFiboUp[1]="FiboUp1 ";
   NameFiboDown[1]="FiboDown1 ";
   NameFiboUp[2]="FiboUp2 ";
   NameFiboDown[2]="FiboDown2";
   NameFiboUp[3]="FiboUp3";
   NameFiboDown[3]="FiboDown3 ";
   NameFiboUp[4]="FiboUp4 ";
   NameFiboDown[4]="FiboDown4 ";
   NameFiboUp[5]="FiboUp5";
   NameFiboDown[5]="FiboDown5 ";
   NameFiboUp[6]="FiboUp6 ";
   NameFiboDown[6]="FiboDown6 ";
   NameFiboUp[7]="FiboUp7 ";
   NameFiboDown[7]="FiboDown7 ";
   NameFiboUp[8]="FiboUp8 ";
   NameFiboDown[8]="FiboDown8 ";
   NameFiboUp[9]="FiboUp9 ";
   NameFiboDown[9]="FiboDown9 ";
   NameFiboUp[10]="FiboUp10 ";
   NameFiboDown[10]="FiboDown10";
   NameFiboUp[11]="FiboUp11 ";
   NameFiboDown[11]="FiboDown11 ";
   NameFiboUp[12]="FiboUp12 ";
   NameFiboDown[12]="FiboDown12 ";
   NameFiboUp[13]="FiboUp13 ";
   NameFiboDown[13]="FiboDown13";
   NameFiboUp[14]="FiboUp14 ";
   NameFiboDown[14]= "FiboDown14";
//---------------------------------------------
NameFiboUp[1]="M1 ";
NameFiboUp[2]="M5 ";
NameFiboUp[3]="M15";
NameFiboUp[4]="H1 ";
NameFiboUp[5]="H4 ";
NameFiboUp[6]="Da ";
NameFiboUp[7]="We ";
NameFiboUp[8]="Mo ";
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   int UP=1;
   int Down=1;
   string  nameUP   = "FiboUp";
   string  nameDown = "FiboDown";
   double FiboDown[4][10],FiboUp[4][10];  // 2x мерный  массив

   int Fibo_Koll = ObjectsTotal(0,0,OBJ_FIBO);     //Запрос колличества объектов Fibo

//_________________________________________________________
   if(Fibo_Koll==0) //Если нет не одного фибо выход        //
      return;                                              //
//_________________________________________________________//

  string n;
//  ObjectName(0,0,0,OBJ_FIBO); //Вытаскивает имя найденого фибо

   for(int i=0; i < Fibo_Koll; i++)
     {
      n=ObjectName(0,i,0,OBJ_FIBO);

      //----------------------------------------------------------------------------------------
      double   Fibo_Level_0= ObjectGetDouble(
                                0,          // идентификатор графика
                                n,              // имя объекта
                                OBJPROP_PRICE,           // идентификатор свойства
                                0     // модификатор свойства
                             );


      double   Fibo_Level_1= ObjectGetDouble(
                                0,          // идентификатор графика
                                n,              // имя объекта
                                OBJPROP_PRICE,           // идентификатор свойства
                                1     // модификатор свойства
                             );
      //------------------------------------------------------------------------------------------------------
      if(Fibo_Level_0>Fibo_Level_1)
        {

         //вызов функции расчёта уровня 78.6
         double Fibo_78_Up = Function_Up(Fibo_Level_0, Fibo_Level_1);
         //--------------------------------------------------------------------
         FiboUp[UP][1]=1;    // Тип объектов 1 == FiboUp
         FiboUp[UP][2]=UP;     // Нумерация объектов FiboUp по типу
         FiboUp[UP][3]=Fibo_78_Up;   // 78.6%
         FiboUp[UP][4]=0;       // 61.8%
         FiboUp[UP][5]=0;         // 50%
     //------------------------------------------------------------------
         //Изменение имени объекта
          bool  F =ObjectSetString(0,n,OBJPROP_NAME,NameFiboUp[UP]);

         UP++;

        }
      else
        {
         //вызов функции расчёта уровня 78.6
         double Fibo_78_Down = Function_Down(Fibo_Level_0, Fibo_Level_1);
         //-------------------------------------------------------------------
         FiboDown[Down][1]=2;    // // Тип объектов 2 == FiboDown
         FiboDown[Down][2]=Down;     // Нумерация объектов  по типу
         FiboDown[Down][3]=Fibo_78_Down;   // 78.6%
         FiboDown[Down][4]=0;       // 61.8%
         FiboDown[Down][5]=0;         // 50%
         Alert("  FiboDown[1][1] = ", FiboDown[1][1],
               "  FiboDown[1][3] = ", FiboDown[1][3],
               "  FiboDown[2][1] = ", FiboDown[2][1],
               "  FiboDown[2][3] = ", FiboDown[2][3]);
         //------------------------------------------------------------------
         //Изменение имени объекта
         bool  F =ObjectSetString(0,n,OBJPROP_NAME,NameFiboDown[Down]);

         Down++;

        }
     }
//+------------------------------------------------------------------+



   Alert("  FiboDown[1][1] = ", FiboDown[1][1],
         "  FiboDown[1][3] = ", FiboDown[1][3],
         "  FiboDown[2][1] = ", FiboDown[2][1],
         "  FiboDown[2][3] = ", FiboDown[2][3]);

   Alert("  FiboUp[1][1] = ", FiboUp[1][1],
         "  FiboUp[1][3] = ", FiboUp[1][3],
         "  FiboUp[2][1] = ", FiboUp[2][1],
         "  FiboUp[2][3] = ", FiboUp[2][3]);


  }

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
double Function_Up(double a, double b)    // имя функции и список параметров
  {
   double Sum_100 = a - b; //Вычисляем 100% В пунктах от точек построения фибо
   double Sum_78  = Sum_100 * 78.6 / 100;  //Вычисляем 78.6% В пунктах
   return (Sum_78 + b);           // Вычисляем 78.6% в цене инструмента
  }
//+------------------------------------------------------------------+
double Function_Down(double a, double b)    // имя функции и список параметров
  {
   double Sum_100 = b - a ; //Вычисляем 100% В пунктах от точек построения фибо
   double Sum_78  = Sum_100 * 21.4 / 100;  //Вычисляем 78.6% В пунктах
   return (Sum_78 + a);           // Вычисляем 78.6% в цене инструмента
  }
//+------------------------------------------------------------------+
 

Who has encountered this

Vin 10

Terminal build 2715.

After I've done any optimisation of the Expert Advisor, after I close the terminal, Agents are still hanging in processes, consuming RAM.


Like not critical RAM volume is a lot, but when I run the game, because of the fact that the memory is constantly referring to a bunch of laggards I have FPS drops by at least 20 frames.

I have to either overload the computer or sit one process at a time to kill...

Honestly already starting to get annoying.

Tell me this bug or so designed, except for the terminal from the broker's opening anything else is not put, from time to time it is updated, any or manipulations with him did not do.

 
Kira27:
Hello!!! Can you tell me may not get it))) The order in the list of objects for some reason if you do not change the names of objects, then when you select and process objects through this loop

order is maintained. But if you change the names with these functions

then the next object is chosen randomly???

Because when an object is renamed, it is recreated. One is deleted, another is created and in the list of all objects they are arranged in order of when they were created.

 
Alexey Viktorov:

Because when an object is renamed, it is recreated. One is deleted, the other is created and in the list of all objects they are arranged in order of when they were created.

Thank you very much!!! Where can I read about this?

Reason: