Hi there,
I am wondering how to figure out the close price and time, when a position was closed by its corresponding stop loss.
The picture shows a part of the history. The original position id was 1253268, it contains no entries for profit or loss. The corresponding stop loss is below, 1253269, this additional order, created by MT5, contains the data, but I don´t see any connection between both. So how is it possible to figure out that the original was closed by stop loss and with which results?
Thanks in advance
https://www.mql5.com/en/docs/trading/historydealselect
- www.mql5.com
Thanks guys, yes, but this does not lead to the corresponding deal. I need a chain from the position (entry #1) to the deal (entry #2), in the shown example, from deal 1223902 to deal ID 1223903. How is it possible to obtain this deal ID by the position with the SL? Because I need all the details/results of the SL execution.
Calculate the difference between the in & out price.
https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties#enum_deal_property_double
- www.mql5.com
Calculate the difference between the in & out price.
https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties#enum_deal_property_double
This sounds like a workaround. I need a reliable connection between the original position/deal and the deal with the SL execution. What if there were 10 positions at different prices and 10 stop losses at the same price? There must be a correct solution to build a chain between them all.
The problem is, when you execute HistorySelectByPosition(1253268), there are no results, all fields are empty when SL was executed, no close price, close time etc.
Damn I'm lazy to write you an example!
HistorySelect(0,TimeCurrent()); for (int i=0;i<HistoryDealsTotal();i++) { long entry = 0; double price = 0; if(HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_ENTRY,entry) && entry == DEAL_TYPE_BUY && HistoryDealGetDouble(HistoryDealGetTicket(i),DEAL_PRICE,price)) { printf("*** price in : %g",price); } }
Damn I'm lazy to write you an example!
I don´t ask for an example, I just ask for the solution. Which is the function and property that tells me the corresponding deal ID with the SL execution? None of the properties I know returns such. If you know more than the documentation does, me and the rest of the MQL world would be glad to know. If I am on the wrong way, I´d be glad to meet the right one.
I don´t ask for an example, I just ask for the solution. Which is the function and property that tells me the corresponding deal ID with the SL execution? None of the properties I know returns such. If you know more than the documentation does, me and the rest of the MQL world would be glad to know. If I am on the wrong way, I´d be glad to meet the right one.
Yes you'll got an example on how to use the function, I don't know how your EA is made. You get the in price, the out price & you make the difference.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
I am wondering how to figure out the close price and time, when a position was closed by its corresponding stop loss.
The picture shows a part of the history. The original position id was 1253268, it contains no entries for profit or loss. The corresponding stop loss is below, 1253269, this additional order, created by MT5, contains the data, but I don´t see any connection between both. So how is it possible to figure out that the original was closed by stop loss and with which results?
Thanks in advance