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

 
Сергей Таболин:

I could be wrong, but I don't think you have any idea how the EA works at all. What do you mean by "program is running"?

A tip - first of all, find out what OnInit, OnTick and OnDeinit are. I think that everything will fall into place ))))

Generally, judging by your answer, you yourself don't really understand how the program works. Since it seems like a silly question. Yes just like the previous commenter thinks it stops. Just from programming experience in other languages I think it executes its body in a loop, and when an event comes, it dives into it. If the program executes its body in a loop, that explains why the program is written that way.
 

Good day all! I am testing an Expert Advisor in MT4.
Can you please advise how to use MQL4 function Print() to print only 1 time in MT4 Tester Log and only with the last hour value. Here is a simple code.

int g;
void OnTick()
{
if (Hour()>g)
{
Print("------------------------------------=",Hour());
g=Hour();
}
}

Print() is printed in the МТ-4 Log-File on each hour.

2020.06.24 15:54:12.250 2010.01.04 06:00:00  ОПТИМ КОДА EURUSD,M1: ------------------------------------=6
2020.06.24 15:54:12.249 2010.01.04 05:00:00  ОПТИМ КОДА EURUSD,M1: ------------------------------------=5
2020.06.24 15:54:12.249 2010.01.04 04:00:00  ОПТИМ КОДА EURUSD,M1: ------------------------------------=4
2020.06.24 15:54:12.248 2010.01.04 03:00:00  ОПТИМ КОДА EURUSD,M1: ------------------------------------=3
2020.06.24 15:54:12.247 2010.01.04 02:00:00  ОПТИМ КОДА EURUSD,M1: ------------------------------------=2
2020.06.24 15:54:12.247 2010.01.04 01:00:00  ОПТИМ КОДА EURUSD,M1: ------------------------------------=1
2020.06.24 15:54:12.214 2010.01.01 00:00:00  ОПТИМ КОДА test started
2020.06.24 15:54:12.196 TestGenerator: spread set to 2
2020.06.24 15:54:09.838 Expert ОПТИМ КОДА EURUSD,M1: loaded successfully
2020.06.24 15:54:09.827 Expert ОПТИМ КОДА EURUSD,M1: removed

But I need Print() to be printed in the MT-4 Logger only once with the last value of the hour. It would be logical to delete the penultimate, i.e. previous Print ( ) entry after the last one appears in the log. I know how to delete an order, a graphic object. But I don't know how to delete Print() entry from the Logbook yet.

Thank you for your help.

Документация по MQL5: Общие функции / Print
Документация по MQL5: Общие функции / Print
  • www.mql5.com
Данные типа double выводятся с точностью до 16 десятичных цифр после точки, при этом данные могут выводиться либо в традиционном либо в научном формате – в зависимости от того, как запись будет наиболее компактна. Данные типа float выводятся с 5 десятичными цифрами после точки. Для вывода вещественных чисел с другой точностью либо в явно...
 
Valeriy Yastremskiy:
No. The tick is not cut off by the examiner. If the EA is running, incoming ticks are skipped. When it finishes, the next tick will start it again in standby mode.
By your logic, it appears that the program will never go to the lot setting function. But that's how the program is written from the official publisher. I have written the order of functions in previous posts.
 
I'll ask again, I'm having second thoughts with previous commenters. The official example suggests counting lot volume in the body of the program, but isn't it logical to calculate it on every tick? What is it written in the body of the program for?
 
I can't install an EA. What do I do? The install button won't click. To be more precise, nothing happens when I press it
 
Сергей Таболин:

Kalash or Maxim? ))))))))))))


Question:

There is a script. It cannot be launched from the EA using the standard means. So, we have to add it to the Expert Advisor as a function. But I do not want to make the same changes in the Expert Advisor when editing the script. How to do it? By means of inclusions?

Classes) and objects
Or by pasting)
 
Ivan_Invanov:
By your logic, it comes out that the software will never go to the lot setting function. But this is how the program is written from the official publisher. I wrote the order of functions in previous posts.
Initialisation and deinitialisation work once. At the beginning and at the end.
 
Ivan_Invanov:
Generally, judging by your response, you yourself don't really understand how the program works. So it seems that it is a silly question. Just like the previous commenter thinks it stops. Just from programming experience in other languages I think it executes its body in a loop, and when an event comes, it dives into it. If the program executes its body in a loop, that explains why the program is written that way.

Judging by your comment, you don't understand that either. (((

This is not "other languages", this is MQL!

Advice to you too - figure out exactly how this bunch works.

All other functions are derived.

Figure it out.

 
Ivan_Invanov:
Yeah, I don't get it, so I'm asking. I know that ontick is an event, but I don't understand where the EA goes afterwards. It will go to the body of the programme and calculate the lot volume, or it won't go? Why has the EA from the official publisher been written in such a way?

And you think someone here is going to start rewriting the documentation for you personally? Just for you? In here? Scratch that yourself....

 
Ivan_Invanov:
Yeah, I don't understand, that's what I'm asking. I know that ontick is an event, it's just not clear to me where the EA then goes. Why has it been written in this way by the publisher?

You would show the code (but you have to understand that if you show the code then the copyright is in plain sight) and the guys will look at the EA's schematic and say what is called and what is not opened a deal or not.

Reason: