Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1062

 

The author of this script, as I understand it, is not from Russia, I'm afraid there is no answer.

So I'm going to ask for help here.

How to fix the warning :

possible loss of data due to type conversion

In this script.

https://www.mql5.com/ru/articles/download/5204/scraperbot04.mq5

 
erotin:

The author of this script, as I understand it, is not from Russia, I'm afraid there is no answer.

So I'm going to ask for help here.

How to fix the warning :

possible loss of data due to type conversion

In this script.

https://www.mql5.com/ru/articles/download/5204/scraperbot04.mq5

Try this

f_US=(float)StringToDouble(StringSubstr(CharArrayToString(ch_Buffer),i,8));
 


Have I correctly understood that in mql5, there are no positions in the history, and there are only deals? Judging by the presence of HistoryDealsTotal() and absence of HistoryPositionsTotal().

Why then, in the History tab of the terminal, you can select "Positions" and they are visible in the history?

How to get the closing price of positions in this history?


 
secret:

Have I correctly understood that in mql5, there are no positions in the history, and there are only deals? Judging by the presence of HistoryDealsTotal() and absence of HistoryPositionsTotal().

Yes.

Why then, in the History tab of the terminal, you can select "Positions" and they are visible in the history?

This is one of the attempts to interpret the history as positions. In my opinion, it is not the most successful one.

How to obtain the closing price of positions in this history?

I do the following on the hedge.

#property script_show_inputs

#include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006

input TICKET_TYPE PositionTicket = 0;

void OnStart()
{
  if (OrderSelect(PositionTicket, SELECT_BY_TICKET))
    OrderPrint();
}
 
Alekseu Fedotov:

Try this

Thank you
 
fxsaber Yes.

It turns out that in order to print a profit of an open trade, you have to work with one list and ticket, and in order to print a profit of the same but closed trade, you have to work with another list and another ticket?

 
secret:

It turns out that to print the profit of an open trade, you have to work with one list and ticket, and to print the profit of the same but closed trade, you have to work with another list and another ticket?

I do not understand the question.

 
secret:

It turns out that in order to print a profit of an open trade, you have to work with one list and ticket, and in order to print a profit of the same but closed trade, you have to work with another list and another ticket?

Each order and each trade has its own ticket, but also has ORDER_POSITION_ID and DEAL_POSITION_ID, respectively. This is what determines whether or not they belong to a position.

 
secret:

How do you get the closing price of the positions in this story?

You should also be well aware that this closing price, even on a hedge, can have more decimal places than Digits.


And it does not have to be even close to the price that was at the symbol at the moment of position closing.

The developers wanted to make an analogy with the MT4 history, but they failed.

When I want to view the trading history in the Terminal, I use the GUI extension. It displays historical positions as in MT4. Close prices correspond to close time, etc.

Therefore, historical positions are a convention that can be given different interpretations.
 
fxsaber:

I do not understand the question.

To calculate the profit of a trade, you need, in particular, the opening price. While the trade is open, the open price has to be taken from the list of positions for the position ticket. And when the deal is closed, then the same open price has to be taken from another list (deals, not positions) for another ticket. Right?

Reason: