Discussion of article "The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument" - page 2

 
ias:


2.What the expression (int) stands for and what value it takes in int DIGITS=(int)-log10(SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP)); if(DIGITS<0)DIGITS=0;


Read about explicit type conversion.
Документация по MQL5: Основы языка / Типы данных / Приведение типов
Документация по MQL5: Основы языка / Типы данных / Приведение типов
  • www.mql5.com
Основы языка / Типы данных / Приведение типов - Документация по MQL5
 
ias:

1.Thanks to the author for the article.
2..What expression (int) means and what value it takes in int DIGITS=(int)-log10(SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP)); if(DIGITS<0)DIGITS=0;
3.Why, during testing, do the expression (int) and SYMBOL_VOLUME_STEP take the values Unknown identifier and how does it affect the result int DIGITS ?
4.How does the interaction code work?
Does the interaction code matter when EAs work on the same instrument, where it is enough to set either identical or different numeric names of EAs.

Expression (int) is a conversion of the following expression to the int type.

The SYMBOL_VOLUME_STEP expression is one of the values of the ENUM_SYMBOL_INFO_INTEGER enumeration.

None of the above expressions is a variable, so naturally they have the value "Unknown identifier" in Debugger,

which literally means "impossible to recognise", Debugger simply cannot understand what type the variable declared for tracking belongs to.


Документация по MQL5: Основы языка / Типы данных / Целые типы / Типы char, short, int и long
Документация по MQL5: Основы языка / Типы данных / Целые типы / Типы char, short, int и long
  • www.mql5.com
Основы языка / Типы данных / Целые типы / Типы char, short, int и long - Документация по MQL5
 
ias:


4.How does the interaction code work?
Does the interaction code matter when EAs work on the same instrument, where it is enough to set either identical or different numeric names of EAs.

Sorry, I got distracted and didn't answer the 4th question.

The interaction code is used as a single magik for several trusted Expert Advisors.

For example, you have an absolutely worked out EA in which you don't want to change anything, but you have created a trailing EA and want to test how it will work with this EA. You start the original EA and the trailing EA and give the same interaction code to both EAs and they will perceive the actions of the other as their own, while the changes made by third EAs without such an interaction code will be ignored (those will be invisible for the selected pair of EAs).

At the same time, you can process some data separately because the EA identification code (digital name) is different,

everything depends on the request as you will form it (for example, you can form a report only on the work of the trawl).

One and the same transaction depending on the request can be defined as your own or someone else's.

[Deleted]  
ias:

1.Thanks to the author for the article.
2..What expression (int) means and what value it takes in int DIGITS=(int)-log10(SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP)); if(DIGITS<0)DIGITS=0;
3.Why, during testing, do the expression (int) and SYMBOL_VOLUME_STEP take the values Unknown identifier and how does it affect the result int DIGITS ?
4.How does the interaction code work?
Does the interaction code matter when EAs work on the same instrument, where it is enough to set either identical or different numeric names of EAs.

As I understand you do not quite understand the meaning of the code, let's understand what happens in detail

int DIGITS=(int)-log10(SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP)); if(DIGITS<0)DIGITS=0;

1. We get the size of the lot volume step for the instrument, SYMBOL_VOLUME_STEP - Minimum volume step to make a trade (Usually it is 0.01);

2. Get the logarithm of the number on the base 10 => -log10(0,01) = 2 or -log10(0,10) = 1 (for MQ it is -log10(0,10) = 1);

3. equate the result (-2/-1) to the variable DIGITS, which is of type int.

4. If the value of DIGITS<0 assign it the value = 0.

PS

(int) is used to force the result of a calculation to the int type...

 

This article does not reflect the event "Stop Loss/Stake Profit occurred". And this is a very strong omission!

Example: an Expert Advisor has two parts: the first one works when the "virtual position" on a given symbol and timeframe is equal to 0, and the second one works when this "virtual position" is not equal to zero; well, let's say the Expert Advisor closes this position. Let's consider a situation: on some signal we made a purchase, the "virtual position" took the value +100. A stop loss has been triggered, the real "virtual position" has taken the value 0. But in our case it will be equal to +100. The Expert Advisor will "think" that the position is +100, but in reality it is 0, which will lead to an undesirable result.

Please explain this point to me.

 
beast:

This article does not reflect the event "Stop Loss/Stake Profit occurred". And this is a very strong omission!

Example: an Expert Advisor has two parts: the first one works when the "virtual position" on a given symbol and timeframe is equal to 0, and the second one works when this "virtual position" is not equal to zero; well, let's say the Expert Advisor closes this position. Let's consider a situation: on some signal we made a purchase, the "virtual position" took the value +100. A stop loss has been triggered, the real "virtual position" has taken the value 0. But in our case it will be equal to +100. The Expert Advisor will "think" that the position is +100, but in reality it is 0, which will lead to an undesirable result.

Please explain this point to me.

That's right, this article does not contain a module for processing stop orders.

It describes the possibilities of using the magic number.

To use a virtual position, virtual stops will be required.

 

Then why do we need magic?

Because if we use it to dig through the history, we will not get a complete picture of the orders placed by this Expert Advisor, because we will not be able to identify stop losses and take profits.

 
beast:

Then why do we need magic?

Because if we use it to dig through the history, we will not get a complete picture of the orders placed by this Expert Advisor, because we will not be able to identify stop losses and take profits.


It is necessary to understand that it is a mistake to use stops as a part of a trading strategy. Stop orders stored on the server are protective orders from situations when something went wrong (communication breakdown with the server, panic in the market), in other cases virtual stop orders in the form of EA signals are quite suitable.

But practice shows that programmers are often lazy to virtualise stops. After all, it is much easier to use ready-made stop orders.

 

When calculating it is necessary to go through all deals, if a deal with a given magician - we take into account its volume, all other deals are checked for the fact of closing by stoploss/stakeprofit, if there is any, then it is necessary to reset the calculated amount. In my article stoploss is not taken into account either. Who would have thought... This is a new topic, you'll have to excuse me.

With this magik there is one more thing, the EA opened a position, you disconnect the EA and close positions manually - that's it, after that there will be incorrect accounting.

And what is the situation: let's say one EA opened buy 0.1, the second EA opened sell 0.1, the cumulative position is equal to 0, and it is considered that there are two counter positions.

In addition to all this we need some means of control, some script to calculate whether the calculated volumes for all mages are consistent with the real volume, we need means of levelling - to open with one mage and close with another.

This raises a big question whether the use of magik will be in demand at all, and if so, how to live with it....

Should we open a separate account for each advisor?

 

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?