Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 867

 
Roman Shiredchenko:

forgot how to update... just downloaded from robot...

I'm not interested in the test, but in the optimisation - which is impossible... because they (the values you set) are reset...

Optimization is a multiple test with different parameters. So the test and optimization is the same for this problem. At the beginning of the test/optimization there is a printout in the journal with which the Expert Advisor was launched. You can pause right after the start and read the log after opening it. And if it is launched with modified parameters, they will be visible in the "Parameters" tab.

As this is a new installation, it's safe to say it's the 2007 release version. This is the second company with this problem. I wonder if running it on MQ will this problem occur? You can update by connecting, or opening a new MetaQuotes-Demo account. And also through the menu


 
Alexey Viktorov:

The optimization is a multiple test with different parameters. So the test and optimization are the same for this problem. At the beginning of the Optimization test the journal has a printout with which parameters the Expert Advisor is running. You can pause right after the start and read the log after opening it. And if you run it with changed parameters, they will be visible in the "Parameters" tab.

As this is a new installation, it is safe to say that this is the 2007 release version. This is the second company with this problem. I wonder if running on MQ will this problem appear? You can update by connecting, or opening a new MetaQuotes-Demo account. You can also do it through the menu.


thanks a lot! Question https://www.mql5.com/ru/forum/305142/page3#comment_11915822 solved by creating the Tester folder manually in MKL.
MT5 самостоятельно сбрасывает настройки в тестере после перехода на вкладку "Настройки"
MT5 самостоятельно сбрасывает настройки в тестере после перехода на вкладку "Настройки"
  • 2019.03.20
  • www.mql5.com
Решение (временное) : Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий MT5 самостоятельно сбрасывает настрой...
 
Why are extern variables not displayed in MQL5 indicator input parameters?
 
Alexandr Sokolov:
Why are extern variables not displayed in MQL5 indicator input parameters?

add

#property strict

And don't use old language constructs, use input instead of extern, I don't remember, but there was a bug with extern, it seems they can be modified in the code, and during a new initialization they are reset to initial values and the compiler does not generate warnings like with input. I may be wrong though.

 
Igor Makanu:

add

And don't use old language constructs, use input instead of extern, I don't remember, but there was a bug with extern, it seems they can be modified in the code, and during a new initialization they are reset to initial values and the compiler does not generate warnings like with input. I may be wrong though.

Differences:

input

extern

Документация по MQL5: Основы языка / Переменные / Input переменные
Документация по MQL5: Основы языка / Переменные / Input переменные
  • www.mql5.com
указывается перед типом данных. Изменять значение переменной с модификатором input внутри mql5-программы нельзя, такие переменные доступны только для чтения. Изменять значения input-переменных может только пользователь из окна свойств программы. Внешние переменные всегда переинициализируются непосредственно перед вызовом OnInit().   Существует...
 
Igor Makanu:

add

And don't use old language constructs, use input instead of extern, I don't remember, but there was a bug with extern, it seems they can be modified in the code, and on new initialization they are reset to initial values and the compiler does not generate warnings like with input. I may be wrong though.

That also does not work for some reason.

extern uint            usp      = 10,          //Update of the panel every ... seconds
                       psize    = 7;           //Panel size


 
Artyom Trishkin:

Differences:

input

extern

I've flipped through it, but there are a lot of questions that aren't interesting ))))

if extern works as written in help, why can't i declare it in function body? - I checked, there is a compiler error:

extern' - unexpected token !!! test11.mq4 35 4

And on a global level, why it is not possible to declare complex data types, like this:

struct S{double f;};
extern struct x;

in general, use of extern raises more questions than the need to use it.

extern is an external global variable that is used to describe variables in other plugins; it may be that MQL libraries need this behavior, but very few people write libraries, all use #include

 
Alexandr Sokolov:

That didn't work either for some reason


checked in indicator even without#property strict

shows the input variables tab, don't know what your problem is, here is my code

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window

extern int x = 10,y=22;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---

   return(rates_total);
  }


 
Alexandr Sokolov:

That didn't work either for some reason


You were told: input and #property strict

They even gave you a link to help.

Документация по MQL5: Основы языка / Переменные / Input переменные
Документация по MQL5: Основы языка / Переменные / Input переменные
  • www.mql5.com
указывается перед типом данных. Изменять значение переменной с модификатором input внутри mql5-программы нельзя, такие переменные доступны только для чтения. Изменять значения input-переменных может только пользователь из окна свойств программы. Внешние переменные всегда переинициализируются непосредственно перед вызовом OnInit().   Существует...
 
Artyom Trishkin:

You were told: input and #property strict

They even gave you a link to help.

Here is my code

#property copyright "Alexandr Sokolov"
#property link      "https://www.mql5.com/en/users/asokolov7"
#property version   "1.00"
#property indicator_chart_window
#property strict

extern uint x = 10, y = 20;
//-------------------------------------------------------------------
int OnInit()
  {
   
  //-----------------------------------------------------------------
   return(INIT_SUCCEEDED);
  }
//-------------------------------------------------------------------
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[])
  {
   
  //-----------------------------------------------------------------
   return(rates_total);
  }