Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1259

 

Afternoon.

A couple of questions on the tester in MT5:

1) In MT5, in the visual testing mode of the Expert Advisor, all the indicators that are calculated through iCustom in the Expert Advisor code are applied to the chart themselves. How can it be disabled/adjusted?

2) I have a single test run in the tester with "visual mode with displaying of charts, indicators and trade" ticked, and then I have the same test run with the ticked off (without visualization). In the first case, the balance chart is drawn quite normally, while in the second case it is just a straight line in some cells. What can this be related to?

 
satorifx:

Afternoon.

A couple of questions on the tester in MT5:

1) In MT5, in the visual testing mode of the Expert Advisor, all the indicators that are calculated through iCustom in the Expert Advisor code are applied to the chart themselves. Can this be disabled/adjusted in some way?


1.TesterHideIndicators().

Документация по MQL5: Общие функции / TesterHideIndicators
Документация по MQL5: Общие функции / TesterHideIndicators
  • www.mql5.com
Задает режим показа/сокрытия индикаторов, которые используются в эксперте. Функция предназначена для управления видимостью используемых индикаторов только при тестировании. По умолчанию на графике визуального тестирования показываются все индикаторы, которые создаются в тестируемом эксперте.  Также эти индикаторы показываются на графике...
 
How to distinguish between the events of deleting a graphical object and renaming a graphical object. In both cases a deletion event is generated. How do I distinguish one from the other?
 
leonerd:
How to distinguish between the events of deleting a graphical object and renaming a graphical object. The deletion event is generated in both cases. How do you distinguish one from the other?

You can't. Renaming is, deleting and creating a new one. So try to catch the creation after deletion.

 
Comments not related to this topic have been moved to "Questions from MQL4 MT4 MetaTrader 4 beginners".
 

Can you tell me what to write to get random 6-digit numbers?

int Random() {
 int r=MathRand(); // 100000 -> 999999
  return(r);
 }
 
Vitaly Muzichenko:

Can you tell me what to write to get random 6-digit numbers?

I found this solution

int Random(int min,int max) {
   int v=0;
   MathSrand(GetTickCount());
   while(true) {
      v=MathRand()*2*MathRand();
      if(v>=min && v<=max)
         break;
     }
   return(v);
  }
 
Vitaly Muzichenko:

Found this solution

Vitaly, this is not the best solution.

First of all, you'd better use a do while loop in that case.

Secondly, in my opinion, it's safer to get a number greater than 6 digits in exponentiation than in multiplication. But in this case it is possible to get INF. But you can limit the value of the power... In my example, the power is no more than 16.

/********************Script program start function*******************/
void OnStart()
 {
  double dr = 0,
         df = 0;
  srand(GetTickCount());
  do
   {
    dr = fabs(rand());
    df = fabs(rand());
   }
  while((dr == 1 || df == 1) && !IsStopped());
  double dp = pow(dr, fmod(df, 16));
  Print(DoubleToString(fmod(dp, 1000000), 8));
 }/*******************************************************************/

And take the remainder of the division and get a six-digit number.

 
Alexey Viktorov:

Vitaly, this is not the best option.

First of all, it's better to use a do while loop in that case.

Secondly, in my opinion, it's safer to get a number greater than 6 digits when it's raised to a power than when it's multiplied. But in this case it is possible to get INF. But you can limit the value of the power... In my example, the power is no more than 16.

And take the remainder of the division getting a six digit number.

Thanks, replaced the part in the code.

 
Vitaly Muzichenko:

Thank you, replaced part of it in the code.

And what was the result? I don't claim to be infallible...)))