Asynchronous and multi-threaded programming in MQL - page 27

 
Roman:

I started to reread the subject and Igor has already written about it.

That's what I was trying to say, Yuri, that we have to allocate memory and register the thread.
Igor says you need to allocate and register, while you say you don't need to do anything.
That's why I am dizzy. The result is a deadlock.

Igor studied at university as a specialist, and he should understand more about it than us self-taught fellows.
From the very beginning I was inclined to the same idea - that memory must be allocated and initialized.
Initialization and memory allocation is the key to correct coding, because it must not flow and must not be rubbish.

So my question to Igor, please explain how to do it in C++?
Not in words, with an example, I don't understand anything ))

Man, you can't multithread on the pros, no offence. But if you're in the ironclad mood, read on and figure it out:

https://en.cppreference.com/w/cpp/thread

https://en.cppreference.com/w/cpp/atomic

If you need an example, see below:

https://en.cppreference.com/w/cpp/thread/thread/join

https://en.cppreference.com/w/cpp/thread/async


Again, this is a tricky subject, easy to nagoconcile (e.g. unhook from a spawned thread that destroys later than the shared data, compiler optimisation in the absence of proper synchronisation and a whole lot more).

 
Реter Konow:
I propose to use the indicator as a carrier of GUI, and resources - for communication with the Expert Advisor. In addition, in MT4, you will be able to control the Expert Advisor tester from a standard chart using the panel. All controls will work, not just buttons. You will be able to send text and anything else to the EA under test. I have already tested it. Everything works.

Peter, you don't understand.

There is ONE advisor. It also runs itself additionally on an invisible chart, only in agent mode. There are NO events running on the agent. I.e., the resource can't call it, the timer won't start, ticks won't come.

If the indicator triggers an EA, these are two entities.

The Expert Advisor can create as many of these agents as it wants. Each one becomes a separate thread.

 
Andrey Barinov:

Peter, you don't understand.

There is ONE advisor. It also runs itself additionally on an invisible chart, only in agent mode. There are NO events running on the agent. I.e., the resource can't call it, the timer won't start, ticks won't come.

If the indicator triggers an EA, these are two entities.

The Expert Advisor can have as many of these agents as it wants. Each one becomes a separate thread.

You mean like launching itself in agent mode on an invisible chart? That's something new. I didn't know about it.
 
Реter Konow:
You mean like running itself in agent mode on an invisible chart? That's something new. I didn't know about it.

ChartApplyTemplate

 
Andrey Barinov:

Peter, you don't understand.

...

An advisor can have as many of these agents as he wants. Each one comes out as a separate stream.

So multithreading already exists? And no one here knows about it?

 
Andrey Barinov:

There is ONE advisor. It also runs itself.

The KB tester has the same principle. Were you able to solve the problem of debugging such an EA? When the tester was made on this principle, the inconvenience of writing it was in the difficulty of debugging.

 
Реter Konow:

Then it turns out that multithreading already exists? And no one here knows about it?

This is called "not hearing your interlocutor".

Forum on trading, automated trading systems and trading strategy testing

Asynchronous and Multithreaded Programming in MQL

fxsaber, 2019.07.25 12:16

In MQL only, both tasks are solved through automatic running of an EA counting.

 
Реter Konow:

Does it mean that multithreading already exists? And no one here knows about it?

It's a well-known trick. It wasn't invented by me. It was invented by me on a forum several years ago.

 
fxsaber:

The CB tester has the same principle. Were you able to solve the problem of debugging such an EA? When I was making the tester on this principle, the inconvenience of writing it was the difficulty of debugging.

Print, ASSERT, DEBUG. I don't use the standard debugger in this case...

 
Andrey Barinov:

It's a well-known trick. It wasn't invented by me. I got it from a forum a few years ago.

How well does this "multithreading" correspond to its notion? Is it possible to split a program's tasks into threads using this function?
Reason: