Dears...
I'm trying to get the open price of an order which already closed in MQL5
as i want to open a position on SL hit, I used HistoryOrderGetDouble (trans.position,ORDER_PRICE_OPEN)
the trans.position return the order number properly. but this function return 0 as open price of the order.
i tried other arguments like ORDER_SL and ORDER_VOLUME in trace mode and they return proper value without issue but open price still is zero.
to make sure i have access to proper history i used HistorySelect with wide range of date as well. but nothing has changed
do you have any idea why this issue happened. is there something wrong in this code or this is a bug in MQL5?
You don't need to refer to orders - you need to refer to DEALS
- www.mql5.com
Thanks Dear...
as you may be aware, deal information related to money information of closed position.
i other word, this doesn't provide you any value regarding to price.
you may see below it cannot return the open price of the closed order.
- www.mql5.com
Thanks Dear...
as you may be aware, deal information related to money information of closed position.
i other word, this doesn't provide you any value regarding to price.
you may see below it cannot return the open price of the closed order.
The order cannot be closed - the order can only be DELETED. And it will be a PENDING ORDER.
If the position is closed - you need to find a DEAL with the "Market exit" type.
Please do not use the word "order". Operate only with such concepts: "Deal" and "Position".
Hi Again,
I checked your way and you are right. but i should use trans.position inside HistoryDealGetDouble.
i could see its result. but still i don't know why i couldn't get result with HistoryPositionGetDouble
if anyone know what is the issue would be nice to know
There is another way - modern: use OnTradeTransaction. Thus, you can catch any transaction, you can also easily see that the transaction occurred as a result of the Stop Loss triggering.
Thanks Vlad...
Actually I'm using this history data check on this Event (OnTradeTransaction)
Main purpose is to find the the original Position information which triggered SL.
i checked your proposed way and it doesn't work again if you have more than 1 Position open and one of them hit SL
Here is the status on history :
Time Deal Order Type Direction Price SL TP
2017.03.02 25 26 Sell in 1.05195 1.5779 1.04536
2017.03.02 26 27 Buy Out 1.05779 1.5779 1.04536
My aim is to get the price of 25 which underlined
in trace mode i can see : trans.position = 26 / trans.deal = 26 / trans.order=27
Thanks Vlad...
Actually I'm using this history data check on this Event ( OnTradeTransaction )
Main purpose is to find the the original Position information which triggered SL.
i checked your proposed way and it doesn't work again if you have more than 1 Position open and one of them hit SL
Here is the status on history :
Time Deal Order Type Direction Price SL TP
2017.03.02 25 26 Sell in 1.05195 1.5779 1.04536
2017.03.02 26 27 Buy Out 1.05779 1.5779 1.04536
My aim is to get the price of 25 which underlined
in trace mode i can see : trans.position = 26 / trans.deal = 26 / trans.order=27
- www.mql5.com
Thanks again...
I'm using the same
if (trans.type == TRADE_TRANSACTION_DEAL_ADD && trans.order_state == ORDER_STATE_STARTED) { PosOpenPrice = ? }
i couldn't find the answer and as result i tried to call the history.
the information returned in trans is related to the final deal which is "buy out". but i need the information of price for "sell in" trade.
in above comment, it would be deal 25 or order 26 in history.
do you have anything in your mind?
Thanks again...
I'm using the same
i couldn't find the answer and as result i tried to call the history.
the information returned in trans is related to the final deal which is "buy out". but i need the information of price for "sell in" trade.
in above comment, it would be deal 25 or order 26 in history.
do you have anything in your mind?
I told you before - stop using the word 'order'. You have a confusion in your head because of this.
Formulate your question already, but only without the word 'order'. Do you want to catch the moment when the position is closed by the triggered Stop Loss?
Dear vlad,
I know what I'm talking about and it is not my mis perception on the different trades definitions. to get aligned you may see my definitions below :
- Position : is a trade which is already open and profit can be changed on each tick
- Order : is the pending orders which you may put by LIMIT and STOP
- Deal : is the action for opening and closing a position or trigger a pending order
the order which i mentioned is not pending order or so... over trade history if you change the view model to deals, you may see the same titles there.
It is the MT5 and MQ5 which is using this ORDER number and return these values on TradeTransaction as well.
Finally to answer your question and clear up the requirement in a sentence:
I'm looking for the OPEN_PRICE of the original Position which its SL hit at the moment.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dears...
I'm trying to get the open price of an order which already closed in MQL5
as i want to open a position on SL hit, I used HistoryOrderGetDouble(trans.position,ORDER_PRICE_OPEN)
the trans.position return the order number properly. but this function return 0 as open price of the order.
i tried other arguments like ORDER_SL and ORDER_VOLUME in trace mode and they return proper value without issue but open price still is zero.
to make sure i have access to proper history i used HistorySelect with wide range of date as well. but nothing has changed
do you have any idea why this issue happened. is there something wrong in this code or this is a bug in MQL5?
Also based on some conversations, I add my real requirement which I'm looking for in a sentence below :
I'm looking for the OPEN_PRICE of the original Position which its SL hit at the moment.