MT5 and trans2quik.dll - page 6

 
prostotrader:

No, I just need to synchronise 3 threads (basically write a Synchronizer), but

I don't know how.

Well, that just leaves flags. We set a flag, wait for others to finish activities, stop and remove their flags, do things, remove the flag. Well, and the logic of flag priority, obviously.

I would not stop the DDE, but let it write to the buffer, so that nothing is lost.

 
Yuriy Asaulenko:

Well, that leaves only the flags. Put up a flag, wait for the others to complete their activities, stop and take down their flags, do the business, take down the flag. Well, and the logic of flag priority, obviously.

I wouldn't stop DDE, though, let it write to the buffer so nothing gets lost.

In other words, the Synchronizer should make a buffer of incoming functions that will be executed depending on the priority?

 
prostotrader:

So the Synchronizer needs to buffer incoming functions that will be executed depending on priority?

No, just suspend the thread(s) according to the relevant flags and their priority. In this variant, nothing else is needed at all.

The second option is to wait for the thread's function to terminate, and then stop it by its flag. This can be necessary, for example, to update the asc-bid, indicators and anything else we need.

For example, flag values.

0 - thread is idle,

1 - thread is on,

2 - request to stop all threads with lower priority.

Set it to 2 and wait until all the threads become 0, execute the program and set it to 0 or 1. By this flag, all other threads resume their work.

 
Yuriy Asaulenko:

No, just suspend the thread(s) according to the relevant flags and their priority. This option does not require anything else at all.

The second option is to wait until the thread's function finishes and then stop it by its flag. This can be necessary, for example, to update the asc-bid, indicators and anything else we need.

For example, flag values.

0 - thread is idle,

1 - thread is on,

2 - request to stop all threads with lower priority.

Set it to 2 and wait until all the threads become 0, execute the program and set it to 0 or 1. By this flag, all other threads resume their work.

You yourself wrote that it is not good to suspend DDE

 
prostotrader:

You yourself wrote that it is not good to suspend a DDE

I just don't understand you.

What I do is this.

1.The server (I have TCP-server) in its thread constantly writes data to the collection like last in first out. There is no need to stop it.

Data is read/deleted from collection in another thread and written to DataTable (it is analog of database table, but in memory). This thread may be paused, if it gets in the way.

3. Another thread reads data from DataTable for analysis. This thread does not interfere with thread 2 since it is being fetched by select and no one except 2 writes data into this table. You can also stop this thread if it gets in the way.

I don't have to pause anything, because I work with one tool and thread 3 is switched to submit-execute orders and follow deals.

 
Yuriy Asaulenko:

I just don't understand you.

What I do is this.

1.The server (I have a TCP server) in its thread constantly writes data to the collection like last in first out. There is no need to stop it.

Data is read/deleted from collection in another thread and written to DataTable (it is analog of database table, but in memory). This thread may be paused, if it gets in the way.

3. Another thread reads data from DataTable for analysis. It does not disturb thread 2 since it is being fetched by select and no one but 2 is writing into this table. You can also stop this thread if it gets in the way.

I don't have to pause anything as I work with one tool and thread 3 is switched to submit-execute orders and follow deals.

Lucky you, I have 52 tools, so I have to switch

 
prostotrader:

You're in luck, I have 52 instruments, so I have to switch

I take it that the analysis of all 52 instruments is done in one thread? Or is it?

What is used as Storage? In my case, with multi-user access, locking is unnecessary and reading doesn't interfere with writing.

The only thing that needs to be blocked is Child's shared access to trans2quik. And only in case of set of threads Child. You can do it by organizing trans2quik in a separate thread and call it on event and simultaneously lock event handler until request is finished. The rest will not get through).

 
prostotrader:

Completely abandoned the idea of linking MT5 and Kvik, settled on Kvik only (DEE server + trans2quik.dll)

What a pity. What's the reason for this decision, are there any serious obstacles in receiving/transmitting data between the two programs?

 
Yuriy Asaulenko:

I take it that the analysis of all 52 instruments is done in one stream? Or is it not?

What is used as Storage? In my case, with multi-user access, locking is unnecessary and reading does not interfere with writing.

The only thing to block is Child's shared access to trans2quik. And only in case of set of threads Child. You can do it by organizing trans2quik in a separate thread and call it on event and simultaneously lock event handler until request is finished. The rest won't get to it).

No, the analysis itself takes place in Child (separately, for each tool) Selector(1,2) chooses which robot to send the data and colbacks

Storage - just tables that are stored in memory

 
Aleksey Vyazmikin:

That's too bad. What's the reason for this decision, is there a serious obstacle to receiving/transmitting data between the two programs?

It just doesn't make sense to make a mess.

Using MT5 we need a code in the Expert Advisor and a DLL, which will receive data.

Using only Quick, we have only one application (see figure with diagram)