PositionSelect
Chooses an open position for further working with it. Returns true if the function is successfully completed. Returns false in case of failure. To obtain information about the error, call GetLastError().
bool PositionSelect( |
Parameters
symbol
[in] Name of the financial security.
Return Value
Value of the bool type.
Note
For each symbol, at any given moment of time, only one position can be open, which is the result of one or more deals. Do not confuse positions with current pending orders, which are also displayed on the "Trade" tab of the "Toolbox" of the client terminal.
The PositionSelect() function works with a timeout. If the requested data are already available, they are given immediately without waiting. Otherwise, the preparation of the requested data may take a fixed timeout of 3 seconds. Once the data are received, the function immediately stops and returns the result.
In most cases the result of the function execution will be given immediately and without any delay, but during re-connections, the specified timeout of 3 seconds provides the necessary time to wait for an update.
If the function fails due to a timeout, error 4757 will be generated. In this case, repeat the request after a short period of time (5-10 seconds).
Function PositionSelect() copies data about a position into the program environment, and further calls of PositionGetDouble(), PositionGetInteger() and PositionGetString() return the earlier copied data. This means that the position itself may no longer exist (or it's volume, direction, etc. has changed), but data of this position still can be obtained. To ensure receipt of fresh data about a position, it is recommended to call PositionSelect() right before referring to them.
See also
PositionGetSymbol(), PositionsTotal(), Position Properties
© 2000-2010, MetaQuotes Software Corp.