Questions from Beginners MQL5 MT5 MetaTrader 5 - page 816

 
Ivan Ivanov:

Only information on 1 (selected ) position is available at any one time :

Are you stating a fact or a reference ? I couldn't find anything like that anywhere with a search.

 
pivomoe:

Are you stating a fact or are you asking for a certificate? I couldn't find anything like that anywhere through a search.

In order to retrieve any position property, the required position must be pre-selected.
You can see any description of the functions for retrieving the properties of PosotionGetXXXX positions in the help:
The function returns the requested property of an open position, previously selected using thePositionGetSymbol orPositionSelectfunction.
You can think of it this way: In the supermarket, if you want to read what is written on the label of a jar of jam, you first have to pick up the jar of jam.
 
fxsaber:
Judging by "which resulted in your error" they did not find the error in 1730, but in an earlier version. I.e. according to the developers in 1730 everything now works perfectly in this respect.
 
Vladimir Karputov:
In order to get any property of the position, it is necessary to select the required position beforehand.
You can see any description of the functions for retrieving the properties of PosotionGetXXXX positions in the help:
The function returns the requested property of an open position, previously selected using thePositionGetSymbol orPositionSelectfunction.
You can think of it this way: In a supermarket, if you want to read what is written on the label of a jar of jam, you first have to pick up the jar of jam.
I understand that we have to select a position and an order before we get their information. I don't see what the CPositionInfo class has to do with it. If we have a class, we can create a lot of objects of this class. And, consequently, each of these objects can be set up for its own position. This is crazy - you can create a million CPositionInfo objects, but all of them will work only with the position that was last selected using the Select() method.
 
pivomoe:
I understand that we have to select a position and an order before getting information about them. I don't understand what does the CPositionInfo class have to do with it? If we have a class, we can create a lot of objects of that class. And, consequently, each of these objects can be set up for its own position. This is nonsense, so you can create at least a million CPositionInfo objects, but they all will work only with the position that was last selected using the Select() method.
The PositionSelect() function copies the position data to the program environment and the subsequent calls toPositionGetDouble(),PositionGetInteger(), andPositionGetString()return the previously copied data
If you want to save an array of data on two or more positions, write your own structure and copy the position data into it.
 
pivomoe:
I understand that you have to select a position and an order before getting information about them. I don't understand what CPositionInfo class has to do with it. If we have a class, we can create a lot of objects of that class. And, consequently, each of these objects can be set up for its own position. This is nonsense, you can create at least a million CPositionInfo objects, but all they will work only with the position that was last selected using the Select() method.
CArrayObj will help you. And store the order/position objects in this list. And get all needed data on them.
 

Let's continue here.

Vladimir Karputov:
The PositionSelect() function copies the position data to the programming environment and subsequent calls toPositionGetDouble(),PositionGetInteger() andPositionGetString()return the previously copied data

I understand all this as it is well explained in the help. I don't understand what this has to do with the CPositionInfo class?

It has a Volume() function . There are requirements before calling this function(select a position before using it). I am fulfilling these requirements. I don't see why it returns absolutely wrong volume. Well, is it so, hard to remember at the time of the last call (for this class object) Select() symbol, which I am interested in, and is already at the time of Volume() call to find the position that corresponds to this symbol and return the volume corresponding to this position?



In other words, using two objects of the PositionInfo class in this case is wrong.

It turns out that there is no sense in the CPositionInfo class, because normally you can work with only one object of this class.

 
I understand correctly that the Volume method of the CPositionInfo class returns the volume corresponding to the point in time when the Select() method was last called? I.e. it is possible to find out the volume that was a month ago for this symbol?
 
pivomoe:

Let's continue here.

I understand all this as it is well explained in the help. I don't understand what this has to do with the CPositionInfo class.

It has a function Volume() . There are requirements before calling this function(select the position before using it). I am fulfilling these requirements. I don't see why it returns the wrong volume. Well really, is it so, difficult to memorize at the time of the last call (for this class object) Select() symbol, which I am interested in, and is already at the time of Volume() call to find the position that corresponds to this symbol and return the volume corresponding to this position?


It turns out that there is no sense in the CPositionInfo class, because normally you can work with only one object of this class.

The CPositionInfo trading class works perfectly when you understand what it does.
Let me explain: CPositionInfo is not a casket that stores all the properties of the selected position, it's a key (convenient, fast, replacing a bunch of lines of code) to access the properties of the selected position.

Reason: