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

 
Artyom Trishkin:

Based on the comment, it is better to track in MQL4 the reason of position closing - by entering "sl[" and "tp[".

But open positions should not be monitored in such a way, since the integrity of the user comment is not guaranteed.

For example, I have several open positions by signal 1 and several open positions by signal 2

I want positions opened by signal 1 to be closed or closed by TP.

And I want the positions in signal 2 to be closed by the opposite signal.

What is the best way to track these positions?

 
Aleksandr Prishenko:

For example, I have several positions open by signal 1 and several by signal 2

Positions opened by signal 1 I want them to be trailed or closed by TP.

I want the positions in signal 2 to be closed by the opposite signal.

What is the best way to track these positions?

MagicNumber

 
Artyom Trishkin:

MagicNumber

Question on coding in MQL5, then tell me on long pos_id .

But to keep track ofthe id of all positions, even those that suddenly closed (to go through the history), to create an algorithm, etc.

Isn't there an easier solution?

 
Aleksandr Prishenko:

Question on coding in MQL5, then tell me on long pos_id .

But to keep track ofthe id of all positions, even those that suddenly closed (to go through the history), to create an algorithm, etc.

Is there no simpler solution?

Do you want to store all of the position IDs and use them to track?

And what if the Expert Advisor is restarted? Or a terminal restart? Or a failure?

We must use the information that is stored on the server, not in the computer's memory. Then you will be able to retrieve it easily in any failure situation.

But if you are doing it for a tester, then of course you can store the necessary information in memory. But I'm afraid that you will have to sweat with it too, because you will have to somehow associate the unknown position identifiers with the actions you need in the TS.

 
Artyom Trishkin:

But I'm afraid you'll have to sweat with it too, because you'll have to somehow associate the unknown position identifiers with the actions you want in the TS.

(Help! )))

SZZY: I often miss the ability to save a script for each of my orders on the server, I did it last year using dynamic lists and save the list in a file to disk - everything works like clockwork, but I need to add in my template methods of writing and restoring from a file - I still can't find it, and when I do, it's not interesting)))https://www.mql5.com/ru/forum/1111/page2488#comment_12158274

 
Artyom Trishkin:

Do you want to store all position IDs in memory and track them?

What if the EA is restarted? Or a terminal restart? Or a failure?

You need to use the information, which is stored on the server, and not in the computer's memory. Then, in any failure you can easily retrieve it.

But if you're doing it for a tester, of course you can store the information you need in memory too. But I'm afraid that you will have to sweat with it too - because you will need to somehow associate the unknown in advance position identifiers with the actions you need in the TS.

Thanks for the recommendations!

 
Igor Makanu:

(Lists to the rescue! )))

ZS: often lacks the ability to save on the server some kind of script for each of the order, did a quick last year through the dynamic lists and save the list to a file on disk - all works like clockwork, but need to add in my template methods of recording and recovery from the file - I do not get together, and when I get together, it's not interesting ))) https://www.mql5.com/ru/forum/1111/page2488#comment_12158274

Well... This is simple for us, and the man asks for something easier at all: even on the magician to trace - says, they say, it is difficult.

 
Aleksandr Prishenko:

Thanks for the recommendations!

You are welcome.

 

Is it possible to create a global variable in the first terminal so that the second terminal can read it? Like a shared file folder for all terminals, only instead of files, there would be global variables that could be read by any of the installed terminals.

 
NastyaMaley:

Is it possible to create a global variable in the first terminal so that the second terminal can read it? Like a shared file folder for all terminals, only instead of files, there would be global variables that can be read by any of the installed terminals.

You can't, search the forum for "data sharing"... there will be many questions, few answers and ... this task is not solved "in 2 clicks"