You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you. But this is a workaround and does not solve the problem when there are multiple entries at the same price.
Which is which? 3 Positions at different prices, but all closed with an SL at the same price.
Thank you. But this is a workaround and does not solve the problem when there are multiple entries at the same price.
No it's not a workaround, looping thru the history is the only way to do it. Then, it's possible to get the position id of an entry with DEAL_POSITION_ID & use HistorySelectByPosition as you did.
https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties#enum_deal_property_integerNo it's not a workaround, looping thru the history is the only way to do it. Then, it's possible to get the position id of an entry with DEAL_POSITION_ID & use HistorySelectByPosition as you did.
If this is the only way, MQ must be kidding. I don´t know what I should look for in the history, because I don´t have the position ID that I need. What I have is my original position ID, and absolutely no information about the SL, nor vice versa from the SL deal to the original one.
No it's not a workaround, looping thru the history is the only way to do it. Then, it's possible to get the position id of an entry with DEAL_POSITION_ID & use HistorySelectByPosition as you did.
https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties#enum_deal_property_integerIf I am wrong, please tell me. Once again: The only thing I know in my EA is the Position ID. How can I find/identify the corresponding SL deal in the history?
If I am wrong, please tell me. Once again: The only thing I know in my EA is the Position ID. How can I find/identify the corresponding SL deal in the history?
HistorySelect list all the deals, you can filter symbols, profit etc ... and get the position id from there.
THEN HistorySelectPosition will retrieve the list of deals involved in that position. You have to reloop thru.
Use the standard lib for that, it's more convenient, original function are boring to use.
Thank you for your effort.
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.