The main problem in mql5 (hedging account) is to know the Stop Loss price, when a position is closed, due to lack of positions history. You can use HistorySelectByPosition() to find your initial Stop Loss (Stop Loss of the initial order), but if you have modified that Stop Loss later, it generates new orders to do it, without the same POSITION_ID, and therefore, they will not be selected by HistorySelectByPosition() function, so it becomes very difficult to know the last Stop Loss you placed.
I don't know if it can be considered as a bug, but if not, it should be.
The main problem in mql5 (hedging account) is to know the Stop Loss price, when a position is closed, due to lack of positions history. You can use HistorySelectByPosition() to find your initial Stop Loss (Stop Loss of the initial order)...
You can use HistorySelectByPosition(), with your POSITION_ID, and then you can find the first order with that POSITION_ID, and check the Stop Loss of this order (HistoryOrderGetDouble(ticket, ORDER_SL). It worked for me, but .the problem is when you modify that Stop Loss later.
Jose Francisco Casado Fernandez: You can use HistorySelectByPosition(), with your POSITION_ID, and then you can find the first order with that POSITION_ID, and check the Stop Loss of this order (HistoryOrderGetDouble(ticket, ORDER_SL). It worked for me, but .the problem is when you modify that Stop Loss later.
Jose Francisco Casado Fernandez: You can use HistorySelectByPosition(), with your POSITION_ID, and then you can find the first order with that POSITION_ID, and check the Stop Loss of this order (HistoryOrderGetDouble(ticket, ORDER_SL). It worked for me, but .the problem is when you modify that Stop Loss later.
And then,checkORDER_POSITION_IDequal toDEAL_POSITION_ID, then checkDEAL_ENTRY,ifOUT,getHystoryDealGetDouble(ticket,DEAL_PRICE).
Ok, and do you know why if you modify the Stop Loss later, the new order generated to do it, doesn't show the same POSITION_ID???. It would the perfect solution for this matter. Is it a bug???. Thanks.
Yes, it's what I was saying. I did it so, and it worked, but if you modify the initial Stop Loss, it generates a new order WITHOUT the same POSITION_ID. I don't know why. I think, it is a bug. Regards,.
No need to lookslippage,because the orderhas beenclose,andclose priceis onHystoryDealGetDouble(ticket,DEAL_PRICE). If theorder has not beeninclose,andyoumake an ordertoclose,then you should considerhow muchslip,so that noerrorrequotes.
Could you please only answer if you know what you are talking about ?
This is a topic about MT5/mql5, I will remove all irrelevant posts.
There is no stoploss price in history on MT5.
The main problem in mql5 (hedging account) is to know the Stop Loss price, when a position is closed, due to lack of positions history. You can use HistorySelectByPosition() to find your initial Stop Loss (Stop Loss of the initial order), but if you have modified that Stop Loss later, it generates new orders to do it, without the same POSITION_ID, and therefore, they will not be selected by HistorySelectByPosition() function, so it becomes very difficult to know the last Stop Loss you placed.
I don't know if it can be considered as a bug, but if not, it should be.
Regards.
The main problem in mql5 (hedging account) is to know the Stop Loss price, when a position is closed, due to lack of positions history. You can use HistorySelectByPosition() to find your initial Stop Loss (Stop Loss of the initial order)...
No you can't or I misunderstood you.
Current Stoploss is nowhere in history.
No you can't or I misunderstood you.
Stoploss is nowhere in history.
.the problem is when you modify that Stop Loss later.
You can use HistorySelectByPosition(), with your POSITION_ID, and then you can find the first order with that POSITION_ID, and check the Stop Loss of this order (HistoryOrderGetDouble(ticket, ORDER_SL). It worked for me, but
.the problem is when you modify that Stop Loss later.
Ok understood now, you are right.
You can use HistorySelectByPosition(), with your POSITION_ID, and then you can find the first order with that POSITION_ID, and check the Stop Loss of this order (HistoryOrderGetDouble(ticket, ORDER_SL). It worked for me, but
.the problem is when you modify that Stop Loss later.
then check DEAL_ENTRY, if OUT, get HystoryDealGetDouble(ticket,DEAL_PRICE).
If DEAL_PRICE equal to HistoryOrderGetDouble(ticket,ORDER_SL), then it means that the Order has been close due to stop loss.
Here's my opninion.
Ok understood now, you are right.
If DEAL_PRICE equal to HistoryOrderGetDouble(ticket,ORDER_SL), then it means that the Order has been close due to stop loss.
And then, check ORDER_POSITION_ID equal to DEAL_POSITION_ID,
then check DEAL_ENTRY, if OUT, get HystoryDealGetDouble(ticket,DEAL_PRICE).
If DEAL_PRICE equal to HistoryOrderGetDouble(ticket,ORDER_SL), then it means that the Order has been close due to stop loss.
Here's my opninion.
What about slippage?
No need to look slippage, because the order has been close, and close price is on HystoryDealGetDouble(ticket, DEAL_PRICE).
If the order has not been in close, and you make an order to close, then you should consider how much slip, so that no error requotes.