Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1333

 
Fast235:

Take Profit triggering

I cannot figure out how and what ORDER_REASON_TP is for,

I know howDEAL_REASON_TP works, but I don't know what to do with orders here

An order is placed by the MT server on condition that the price reaches the TP level of the open position and the trade is corresponding. But there is no such thing in MT4 ;)

 
Fast235:

Take Profit triggering

I cannot figure out how and what ORDER_REASON_TP is for,

I have some idea howDEAL_REASON_TP works, but I do not know what is going on with orders here

How can there be a transaction without an order (order = order)?

The order system of 4 is greatly simplified from that of 5. And you have to have all the data.

 
Valeriy Yastremskiy:

And how can there be a transaction without an order (warrant = order)

The order system of 4k is greatly simplified from 5k. And you have to have all the data.

So to open a new order with a double lot or a coup trade we look at the result of closing the position, I do not understand what the result of the order has to do with it.

 
Fast235:

So to open a new order with a double lot or a reversal trade, we look at the result of closing the position, I do not understand what the result of the order has to do with it.

You just need to understand the order system of MT5. It's simple, you place an order, when it is executed a deal is created (and written in the history), it generates a position. Also when you close it.

 
Fast235:

To open a new order with a double lot or a coup trade, we look at the closing result of the position, I do not understand what the result of the order has to do with it.

An order is an order in 5. In 4, a market order is an executed order. In 5, a TakeProfit is an order to close a position.

 

Please advise how to skim the profit of a historical trade in pips in mt5. With HistoryDealGetDouble() you can get the price and profit of the deal. Using the HistoryDealGetInteger(), you can obtain the order, on the basis of which the deal is executed, and the direction (entry, exit, etc.). Can we somehow obtain the deal that is on the entry, associated with the one on the exit? Are they somehow linked by a special number?

So far I see such (complicated) options:

1. Using the result of a trade, by its volume and cost of a point, derive a profit in points;

2. I suggest that we may use the position identifier somehow.


Will these variants work and are there any simpler ones?

 
Yevhenii Levchenko:

Please advise how to skim the profit of a historical trade in pips in mt5. With HistoryDealGetDouble() you can get the price and profit of the deal. Using the HistoryDealGetInteger(), you can obtain the order, on the basis of which the deal is executed, and the direction (entry, exit, etc.). Can we somehow obtain the deal that is on the entry, associated with the one on the exit? Are they somehow linked by a special number?

So far I see such (complicated) options:

1. Using the result of a trade, by its volume and cost of a point, derive a profit in points;

2. I suggest that we may use the position identifier...


Will these variants work and are there any simpler ones?

Exactly. POSITION_IDENTIFIER

 
Alexey Viktorov:

Exactly. POSITION_IDENTIFIER

In a hedge account, does this mean that two trades (entry and exit) are linked within the same position? And if it is a netting account? There may be a lot of trades in one position. Can they be linked somehow inside (entry and exit)?

Or is it easier not to bother and more correct to withdraw the profit in pips according to a deal result, by its volume and value of a pip ?

 
Yevhenii Levchenko:

In a hedge account are the two trades (entry and exit) linked within one position? What if it is a netting account? There may be a lot of trades in one position... Can they be linked somehow inside (entry and exit)?

Or is it easier not to bother and more correct to withdraw the profit in pips according to a deal result, by its volume and value of a pip ?

There is always a zero trade, the first one with type IN and the last one with type OUT and they all have one POSITION_IDENTIFIER. Here's if there were multiple closes in parts, then this needs to be checked carefully. I haven't tried it, but everything can be solved, and I have no doubts about it. Any profit in pips is always calculated depending on the volume, therefore it must be calculated by opening and closing volumes.

I am against the universality of functions, so I do not invent all sorts of nonsense that bullshit SMS can put in the brain.

 
Alexey Viktorov:

There is always a null trade, the first with time type IN and the last with time type OUT and they all have the same POSITION_IDENTIFIER. But if there were several closures in parts, then this has to be checked carefully. I haven't tried it, but everything can be solved, and I have no doubts about it. Any profit in pips is always calculated depending on the volume, therefore it must be calculated by opening and closing volumes.

I am against the universality of functions, so I do not invent all sorts of nonsense that bullshit SMS can put in the brain.

OK, thanks :)
Reason: