New article The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument is published:
This article considers the questions of information coding, using the magic-identification, as well as the division, assembly, and synchronization of automatic trading of different Expert Advisors. This article will be interesting to beginners, as well as to more experienced traders, because it tackles the question of virtual positions, which can be useful in the implementation of complex systems of synchronization of Expert Advisors and various strategies.
Please correct me if I'm wrong...
I have to try something similar to your code here to discriminate operations and positions of different EAs. I have several doubts. Is this code optimized? I think this code could really slow down the computer if you have a long history of trades and several eas running this code -alghough I haven't yet proved it, that's only what I think.
For example, in the file magic_exp1_en.mq5, the method prHistory_Deals(ulong &buf,int HTD) fills the buffer buf with all the deals we've had.
Wouldn't it be better for performance if we stored only the last DEAL IN not yet filled by a DEAL OUT?
Maybe I haven't understood really what the code does. What I think the code does in magic_exp1_en.mq5 is: for the entire history of deals since the beginning of time :-) , it checks if the sum of volumes of all the DEAL_TYPE_SELL and DEAL_TYPE_BUY is the same, in which case we don't have a position open. If the volume of the SELLs is higher than the volume of BUYs, then we have a general SELL position, and a BUY position if the volume of the BUYs is higher than that of the SELLs.
Isn't there other way?