Errors, bugs, questions - page 515

 
I am interested in the formula to calculate the total average position for orders of the same direction, taking into account the spread. Unfortunately, I did not find it in my search. Thanks in advance.
 
Konstantin83:
Question: From which section can I download the MQL5 manual as a chm or pdf file? The link https://www.mql5.com/files/docs/mql5_russian.chm works, but which section should I download it from? It used to be from the Documentation section, but now it is only online documentation.

Are there no links available from the Documentation section of the website(https://www.mql5.com/ru/docs)?


 
Rosh:
The transaction is active only at the moment of the transaction so nothing can be changed/zeroed. Do you mean a closing magic order? In manual trading, a magik is not assigned to the orders as well as to the trades on the basis of which the orders are placed.

The sequence is as follows:

  1. a pending order was placed by the Expert Advisor with a non-zero magic number
  2. the order was triggered and the position opened
  3. the position is closed manually
Question: will this closed trade have a non-zero magic number or will it be zero?
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
Dima_S:

The sequence is as follows:

  1. a pending order was placed by the Expert Advisor with a non-zero magic number
  2. the order was triggered and the position opened
  3. this position was closed manually
Question: will this closed trade have a non-zero magic number or will it be zero?

Answer: Properties of trades

A deal is a reflection of the fact that a trade operation has been executed on the basis of an order containing a trade order. Each deal is described by properties that allow obtaining information about it. Toread the values of the properties, the functions of the HistoryDealGet...()type are used , which return values from the corresponding enumerations.

For the HistoryDealGetInteger() function

ENUM_DEAL_PROPERTY_INTEGER

Identifier

Description

Type

DEAL_ORDER

Order on the basis of which the trade was executed

long

DEAL_TIME

Deal execution time

datetime

DEAL_TYPE

Deal type

ENUM_DEAL_TYPE

DEAL_ENTRY

Deal direction - market entry, market exit or reversal

ENUM_DEAL_ENTRY

DEAL_MAGIC

Magic number for the deal (see ORDER_MAGIC)

long

DEAL_POSITION_ID

Identifier of the position, in the opening, modification or closing of which this deal was involved. Each position has a unique identifier, which is assigned to all deals performed on the instrument during the life time of the position.

long

 

This has also been tried:

deal_order = ( long )HistoryDealGetInteger( deal_ticket, DEAL_ORDER );
deal_magic = ( ulong )HistoryOrderGetInteger( deal_order, ORDER_MAGIC );
The result is also a null value returned.
 
Interesting:

As I understand it, before retrieving the properties of a particular transaction you need to select it using - HistoryDealSelect

HistoryDealSelect

Selects the deal in the history for further access to it through the appropriate functions. Returns true if the function completes successfully. Returns false when the function fails. To get the information about the error, you need to call the GetLastError() function.

TheHistoryDealSelect(
ulong ticket//ticket of the deal
);

Parameters

ticket

[in] Ticket

Returned value

Returns true if successful, otherwise false.

You don't quite get it right.

HistoryDealGetTicket also selects the deal.

 
Dima_S:

You don't quite get it right.

HistoryDealGetTicket also selects the deal.

No, you're doing it right. It's just that when you set an order (make a trade) manually, Magic is not set (default = 0). That's what it's designed for, so that the EA can distinguish its own transactions from all other transactions. If you want to link all operations on a position, EA and manual, use POSITION_IDENTIFIER, it will be the same for all transactions.

 
Valmars:

So what you are saying is that with this sequence of operations:

  1. a pending order was placed by the Expert Advisor with a non-zero magic number
  2. the order was triggered and the position opened
  3. this position was manually closed

the resulting deal will have a zero magic number in the history and there will be no way to get it?

 
Dima_S:

So what you are saying is that with this sequence of operations:

  1. a pending order was placed by the Expert Advisor with a non-zero magic number
  2. the order was triggered and the position opened
  3. this position was manually closed

the resulting deal will have a zero magic number in the history and there is no way to get it?


A deal's magic is determined by the order's magic as a result of the execution of which it was performed. But when manually sending a request to perform a deal (order), can you set a magik? Yes, the resulting deal will have a zero magic number in the history. It can be obtained and it will be 0 (which means that the magician is not set).

Maybe we are talking about different things? In the order you have given, there would be two trades, the first one was triggered and the second one - when the position was manually closed, its magic number would be 0.
 
Valmars:

The magik of a transaction is determined by the magik of the order that caused it to be executed. And manually sending a request for a transaction (order), can you set a magik? Yes, the resulting deal will have a zero magic number in the history. It can be obtained and it will be 0 (which means that the magician is not set).

Maybe we are talking about different things? In the sequence given by you, there would be two trades, the first order triggered, the deal with a magic number set in the order and the second one - when the position was closed manually, its magic number would be 0.
Are you suggesting to use position identifier?