Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1036

 
Evgeny Dyuka:
You write"A closed position (this is when there is no position and it is useless to talk about it as something tangible - there is no position) - the result of the execution of a deal to exit the market". It turns out that there is no such single entity in the history, but there is a set of events - order->trade (opening), order->trade (closing) and it all has no single name.
I just can't solve a trivial problem - I need to refer to this last entity (by tickit probably) and collect information about it - opening/closing time, volume, etc. Suppose that this something was opened by one order and closed by one order too. So, we should take the last two orders from HistoryOrderTotal and use them for some analysis? What if the ticket types are different...
How such a reference to the history is solved in practice?

Try to understand the structure of MqlTradeTransaction. After getting the last order or deal from the history, we can collect in an array all of the orders and/or deals that took part in the formation of the position. Thus, all of the information about the position can be gathered from these deals.

Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура торговой транзакции
Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура торговой транзакции
  • www.mql5.com
Например, при отсылке рыночного ордера на покупку он обрабатывается, для счета создается соответствующий ордер на покупку, происходит исполнение ордера, его удаление из списка открытых, добавление в историю ордеров, далее добавляется соответствующая сделка в историю и создается новая позиция. Все эти действия являются торговыми транзакциями...
 
Evgeny Dyuka:
You write"A closed position (this is when there is no position and it is useless to talk about it as something tangible - there is no position) - the result of an exit trade". It turns out that there is no such single entity in the history, but there is a set of events - order->trade (opening), order->trade (closing) and it all has no single name.
I just can't solve a trivial problem - I need to access this last entity (by tickit probably) and collect information about it - opening/closing time, volume, etc. Suppose that this something was opened by one order and closed by one order too. So, we should take the last two orders from HistoryOrderTotal and use them for some analysis? But what if the tickets are different...
How would such a reference to the history be implemented in practice?

The position identifier is always equal to the ticket of its very first order - the order to open this position, and during the time of its existence it (identifier) never changes (unlike tickets). So, in order to find all orders and deals of a certain position, look for it by its identifier - they will all exactly belong to the position you are looking for.

The order has ORDER_POSITION_ID, the deal has DEAL_POSITION_ID, and the position has POSITION_IDENTIFIER

 
Artyom Trishkin:

The position identifier is always equal to the ticket of its very first order - the order to open this position, and during the time of its existence it (identifier) never changes (unlike tickets). Therefore, in order to find all of the orders and deals of a certain position, look for them by their position identifier - they will all exactly belong to the position sought.

The order has an ORDER_POSITION_ID, the deal has a DEAL_POSITION_ID, and the position has a POSITION_IDENTIFIER.

I see, a little bit clearer
 
Alexey Viktorov:

Try to understand the structure of MqlTradeTransaction. By getting the last order or deal from the history, we can collect all orders and/or deals that were involved in the formation of the position in an array. Thus, all information about the position can be gathered from these deals.

mql4 has got used to simplicity, of course, everything is correct in 5, but you can't get into the theme easily
 
Hi friends! Help me solve a problem with the indicator. The indicator shows correct data only after refreshing the page. If you do not refresh the page, it hangs at the same level without changing, not depending on the price jumps.Below I attach the indicator and screenshots before and after refreshing the page. p.s. on the screenshots you need to watch the last 30-40 bars!
Files:
TrailCD.mq5  6 kb
Si-6.19M1.png  63 kb
1Si-6.19M1.png  64 kb
 
Give me a link to an example of implementation of this trailing stop, because it's all written cleverly, but in practice we mere mortals do not understand.
 
Evgeny Dyuka:
If you give me a link to the example of implementation of this Stop Loss, it is all written cleverly, but in practice we mere mortals do not understand.

Use the MQL5 Wizard to generate any Expert Advisor. When selecting options, check that Trailing is required. This will give you an example.

 
Vladimir Karputov:

Use the MQL5 Wizard to generate any Expert Advisor. When selecting options, check that Trailing is required. This will give you an example.

Great! Thank you!
 

Hello!

There is a draw_none drawing style, the buffer is displayed in the data window, but is not drawn on the chart.

Is there a reverse property, it is not displayed in the data window, but is displayed on the graph?

 
SEM:

Hello!

There is a draw_none drawing style, the buffer is displayed in the data window, but is not drawn on the chart.

There is a reverse property, it is not displayed in the data window, but it is displayed on the chart?

There are. PLOT_SHOW_DATA.

Документация по MQL5: Константы, перечисления и структуры / Константы индикаторов / Стили рисования
Документация по MQL5: Константы, перечисления и структуры / Константы индикаторов / Стили рисования
  • www.mql5.com
При создании пользовательского индикатора можно указать один из 18 типов графического построения (способа отображения на главном окне графика или в подокне графика), значения которых указаны в перечислении ENUM_DRAW_TYPE. В зависимости от стиля рисования, может потребоваться от одного до четырех буферов значений (отмеченных как...
Reason: