Asynchronous and multi-threaded programming in MQL - page 28

 
Andrey Barinov:

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

Yes, that's an inconvenience. Almost like in old MQL4.

 
Реter Konow:
And how does such "multithreading" correspond to its notion? Is it possible to split program tasks into threads using this function?

For certain tasks 100%. For example, you need to manage trades - Trawl or something else.

This task can be performed on the agent on every tick for as long as you like and the GUI will still work.

 
Andrey Barinov:

With this scheme, protections are made

  • Against someone closing OBJ_CHART. For example, someone's "smart" script.
  • The mechanism of the friend-or-foe evement is not only by ID.
Data exchange via files - no physical problems with disk? Seems to me that all market copiers are doing something awful because of this synchronisation.


What flag do you use to identify slave/master EA mode? If I use OBJ_CHART then it's a slave. And in MT4? My input was datetime, so I easily solved it using a negative datetime. But I haven't tried it without input.

 
Andrey Barinov:

For certain tasks 100%. For example, you need to manage trades - Trawl or something else.

This task can be performed on an agent on every tick for as long as you like and the GUI will still work.

It is still a dark forest. The function saves the chart template and then, can I open a new chart from the EA and apply the saved template to it, and in doing so, a copy of the EA will run on that chart?
 
fxsaber:

With this scheme, protections are made

  • Against someone closing OBJ_CHART. For example, someone's "smart" script.
  • The mechanism of the friend-or-foe evement is not only by ID.
Data exchange via files - no physical problems with disk? Seems to me that all market copiers are doing something awful because of this synchronisation.

Yes, protection is needed, as always.

Files should be used wisely. Only when needed. Only moments of significant environment / state changes that the agent itself cannot recognize are synchronized.

The copycat is usually running on a VPS, so it's not really a big deal.

 
Andrey Barinov:

Copycats usually work on a VPS, so it's not too scary.

Poor VPS... above supplemented the question.

 
Реter Konow:
Still a dark forest. The function creates a saved copy of the chart and then, can I open a new chart from the EA and run the saved template on it, and in doing so, the copy of the EA will run on that chart?

1.The user places the EA on a blank chart.

2. The EA creates a template (with itself on the chart)

3. The Expert Advisor creates a new chart (OBJ_CHART or a normal chart in case of MT4)

4. The Expert Advisor applies the template to the new chart.

5. A copy of the EA starts on the new chart, now it should understand that this is the agent, not the main EA :)

6. They start communicating.

They live happily ever after and die on the same day :)

 
fxsaber:

Poor VPS... above supplemented the question.

You can't make a copy without files (for the marketplace). And trading environment synchronisation files between terminals take much more operations than synchronisation between agents.


The agent in MT4 is determined by the presence of appropriate global variables which are set by the main EA before applying a template to a new chart.

 
fxsaber:

Poor VPS... above supplemented the question.

You have to take into account that OS doesn't axe writes to disk, it knows how to cache. I can't remember where, but there's even a setting somewhere in wind.

 
Andrey Barinov:

1.The user places the EA on a blank chart.

2. The EA creates a template (with itself on the chart)

3. The Expert Advisor creates a new chart (OBJ_CHART or a normal chart in case of MT4)

4. The Expert Advisor applies the template to the new chart.

5. A copy of the EA starts on the new chart, now it should understand that this is the agent, not the main EA :)

6. They start communicating.

They live happily ever after and die on the same day :)

Cool!)) Thanks!

Yeah, that's the kind of multithreading. You need to run for each heavy task a copy of the EA on a separate chart via a template and tell that copy to only perform the function you want it to perform. The other functions of the copy can rest.

Will communication via resources with copies on regular charts (not OBJ_CHART) take place? Or are there any restrictions?

Reason: