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

 
MakarFX:

Closing MetaQuotes Demo Server

MetaQuotes Software Corp.

4 March 2009

On April 5, 2009 server "demo.metaquotes.net" will be shut down. However, the History Center with the minute history will continue its work.

From this day our company refuses to use demo server. Nowadays, the number of companies running MetaTrader 4 platform is so high, that we do not see the need to maintain our own server.

This is some kind of antiquity (another server is mentioned). It's been done many times this year, the last time was a month ago on MetaQuotes-Demo a new demo account was created normally.

Also, if the server is removed why is it shown and pinged in the account opening wizard? The jam happens only on the last step.

 
Artyom Trishkin:

The first time historical data is accessed from the indicator, if there is insufficient local data, data loading starts and the function returns an error.

This I understand perfectly. If it were about insufficient bars in the history, then both functions would return 0. However, one of them returns 0, while the other one correctly returns the number of bars in the history. Moreover, they are called one after the other:

Loader(): symbol(Symbol()), timeframe(Period()) 
  {
    Print(__FUNCTION__ + " symbol: " + symbol + " timeframe: " + EnumToString(timeframe));
    ResetLastError();
    Print(__FUNCTION__ + " bars: " + (string)iBars(symbol, timeframe)); // Данный вызов iBars() даёт 0 при перезапуске терминала
    Print(__FUNCTION__ + " Error: " + (string)GetLastError());
    Print(__FUNCTION__ + " bars (2): " + (string)iBars(Symbol(), Period())); // Этот же вызов iBars() работает нормально
  }

Only the data in the first case is taken from the ready premembers (symbol and timeframe) of the Loader class (correctly initialized), but in the second case, from Symbol() and Period() functions (which return exactly the same values as written in symbol and timeframe). The values of the variables are identical to those of the functions (I checked). But it's not clear where iBars(symbol, timeframe) messes up with absolutely correct symbol and timeframe. While iBars(Symbol(), Period()) doesn't make a mistake. So I decided that it must be an error in the terminal itself or incorrect compilation of the source code.

Документация по MQL5: Доступ к таймсериям и индикаторам / Bars
Документация по MQL5: Доступ к таймсериям и индикаторам / Bars
  • www.mql5.com
Если указаны параметры start_time и stop_time, то функция возвращает количество баров в диапазоне дат. Если эти параметры не указаны, то функция возвращает общее количество баров. Если данные для таймсерии с указанными параметрами при вызове функции Bars() еще не сформированы в терминале, или данные таймсерии в момент вызова функции не...
 
Mihail Matkovskij:

I understand this very well. If it were about lack of bars in the history, then both functions would return 0. But as it is, one function returns 0, while the other correctly returns the number of bars in the history. Moreover, they are called one after the other:

Only the data in the first case is taken from the ready premembers (symbol and timeframe) of the Loader class (correctly initialized), but in the second case, from Symbol() and Period() functions (which return exactly the same values as written in symbol and timeframe). The values of the variables are identical to those of the functions (I checked). But it's not clear where iBars(symbol, timeframe) messes up with absolutely correct symbol and timeframe. While iBars(Symbol(), Period()) doesn't make a mistake. So I decided that there is an error somewhere in the terminal's operation.

Now write it like this, as Igor advised:

Loader(): symbol(Symbol()), timeframe(Period()) 
  {
    Print(__FUNCTION__ + " symbol: " + symbol + " timeframe: " + EnumToString(timeframe));
    ResetLastError();
    Print(__FUNCTION__ + " bars: " + (string)iBars(Symbol(), Period())); // Данный вызов iBars() даёт 0 при перезапуске терминала
    Print(__FUNCTION__ + " Error: " + (string)GetLastError());
    Print(__FUNCTION__ + " bars (2): " + (string)iBars(symbol, timeframe)); // Этот же вызов iBars() работает нормально
  }
And don't forget that this is a class constructor, and it is called before initialisation
 
Mihail Matkovskij:

I understand this very well. If it were about lack of bars in the history, then both functions would return 0. But as it is, one function returns 0, while the other correctly returns the number of bars in the history. And they are called one after another:

You come up with a story

and then you decide to write it as a claim and then the question

What does the 4401 error help say?

what did I write?

Do you understand the difference between a lack of bars and a chart not being ready ?

you have the situation after the restart of the terminal with the start of the indicator, and you request the data in the global initialization of MQL-program (class constructor), which will be executed before OnInit()


gone, you write faster than you read, search the forum 4401 - all the answers

 
MakarFX:

I calculate the lot as follows

It is at the beginning of the EA...and I put it at the very end of the code

#property link      "http://www.mql5.com"
input double CheckLots = 0.01;
input int    Persent   = 5;
   double Lots=NormalizeDouble(AccountBalance()*CheckLots/1000-0.005,2);  

When the Lots variable is called in the OnTick function, the EA finds and recalculates it.

It can't be like that. The declaration and initialization are going on, and theLots variable is being assigned with an expression.

NormalizeDouble(AccountBalance()*CheckLots/1000-0.005,2)

This assignment can be performed only once at startup. It can't be the case, that an expression is automatically assigned each timeLots is accessed. I haven't heard that mql can do that.

 
Seric29:

It can't be like that. You have declaration and initialization, and an expression is assigned to theLots variable.

This assignment can be done once at startup, it can't be that each time you accessLots, an expression is automatically assigned. I haven't heard that mql can do that.

I checked, when the balance changes, the lot changes too
 
MakarFX:
I checked, when the balance changes, the lot also changes

Wow, I'll check it out. I know you can initialize variables with array elements with functions, but I didn't know it automatically changes, I don't think there's any such thing in C++ either, I'll check later.

 
Artyom Trishkin:
And do not forget that this is a class constructor, and it is called before initialization

This is if the object is automatic. But I create it with keywordnew (in OnInit()) and delete it with keyword delete (in OnDeinit()). That is, I use a pointer to an object of Loader type. But I think you know all the details about it. That's why the loader is created in OnInit() and there cannot be any error here.

If you mean swapping functions, I've tried it and the result is the same. Only the messages go in a different sequence :)

public:  
  Loader(): symbol(Symbol()), timeframe(Period()) 
  {
    Print(__FUNCTION__ + " symbol: " + symbol + " timeframe: " + EnumToString(timeframe));
    Print(__FUNCTION__ + " bars (2): " + (string)iBars(Symbol(), Period())); 
    ResetLastError();
    Print(__FUNCTION__ + " bars: " + (string)iBars(symbol, timeframe)); 
    Print(__FUNCTION__ + " Error: " + (string)GetLastError());
  }

Result:

2020.06.24 23:10:48.568 Loader::Loader symbol: EURUSD timeframe: PERIOD_H1

2020.06.24 23:10:48.568 Loader::Loader bars (2): 140435

2020.06.24 23:10:48.568 Loader::Loader bars: 0

2020.06.24 23:10:48.568 Loader::Loader Error: 4401

Please note that this only happens if and only if the terminal is restarted! Because at first startup of terminal (after Windows startup) this example works correctly.
Запуск платформы - Для продвинутых пользователей - Справка по MetaTrader 5
Запуск платформы - Для продвинутых пользователей - Справка по MetaTrader 5
  • www.metatrader5.com
По завершении установки в меню "Пуск" создается группа программ торговой платформы, а на рабочем столе дополнительно помещается ярлык программы. Используйте их для запуска. Нельзя запускать одновременно две копии платформы из одной директории. Чтобы одновременно запустить несколько копий, установите соответствующее количество программ в разные...
 
Igor Makanu:

You made up some story.

and then decided to make it into a complaint.

No claims! And what's the story if I provided the source code and even described the sequence of actions to test its work? Obviously, you have misunderstood me ...

Igor Makanu:

And you're asking for data in global initialization of MQL-program (class constructor), which will be executed before OnInit()


gone, you're writing faster than reading,search the forum 4401 - all the answers


It should not be executed beforeOnInit(), I wrote in a previous post. It's you who are not reading carefully, both the posts and the source code I added for testing.

 
Stanislav Korotky:

This is some antiquity (another server is mentioned). More than once this year, last time a month ago on MetaQuotes-Demo a new demo account was created normally.

Also, if the server is removed why is it shown and pinged in the account opening wizard? The jam happens only on the last step.

Yeah, something is not registering, even in the mobile terminal. Earlier this year everything was registering.