Typical mistakes and how to deal with them when dealing with the trading environment - page 9
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Good afternoon!
I have a similar question for everyone and especially for fxsaber.
It seems to be a primitive question, but I can't find the answer to it.
Here https://www.mql5.com/ru/forum/6343/page939 I was told "Try to search for it. fxsaber has been working on this problem for a while now. What worked out, I don't know, I'm not interested." So I decided to ask you.
The question is this. I opened position and want to print the content of MqlTradeResult:
retcode, order and volume are printed, but deal and price are always zeros.
Please, advise me what I'm doing wrong and how to get access (at least, print it first) to the content of result structure?
How about this?
I open a position and want to print the content of MqlTradeResult like this:
retcode, order and volume are printed but deal and price are always zeros.
Please advise what I'm doing wrong and how to get access (at least print it first) to the contents of result structure?
Zeros are written in result.
How about this?
Zeros and are prescribed in the result.
I see an open order, I get result.retcode 10009 and result.price = 0 ?
Can you please explain the meaning of result if it doesn't contain a result ?
Please explain what is the point of the result if it does not contain the result?
This is a feature of MT5 where the result is only an order (ticket and no price) but not a trade. You have several options
This is a feature of MT5 where the result is only an order (ticket and no price) but not a trade. You have several options
In MQL4 there was no result structure and we received a ticket and selected the appropriate order and requested the necessary data. MQL5 has the result structure that contains many necessary data, and it would be illogical not to use it.
1. Before asking a question on the forum, I tried to "Figure out for myself how everything works" and what I see - in the result structure:
outputs result.deal, i.e. it is assumed to make sense and it is not always represented by zero in the result structure. Other examples could be given that indicate that result.price as well as result.deal can be obtained from MqlTradeResul, which is what I tried to do.present double price; // Deal price, confirmed by broker.
In the sample code from the developer
Nowhere have I seen information that "This is a feature of MT5, when the result is only an order (ticket and no price), but not a deal". Would you please tell me based on what information you came to this conclusion.
2. If you know of any "already ready higher level (low level is hidden) developments," which allow you to obtain the parameters of a position immediately after its opening (code 10009 appears), without prior selection by ticket, please give me an example or give me a link to it.
Thank you.
In MQL4 there was no result structure and we received a ticket and selected the appropriate order and requested the necessary data. MQL5 has the result structure with many necessary data and it would be illogical not to use it.
1. Before asking a question in the forum, I tried to "figure out for myself how everything works" and what I've seen is that the structure result:
outputs result.deal, i.e. it is assumed to make sense and it is not always represented by zero in the result structure. There are other examples that show that result.price as well as result.deal can be obtained from MqlTradeResul, which is what I tried to do.There is a double price; // Deal price, confirmed by broker.
In the sample code from the developer
Nowhere have I seen information that "this is a feature of MT5 where the result is only an order (ticket and no price) but not a deal". Would you please tell me based on what information you came to this conclusion.
2. If you know of any "already prepared higher level (low level is hidden) developments," which allow you to get the parameters of a position immediately after its opening (code 10009 appears), without prior selection by ticket, please give me an example or give me a link to it.
A trade request results in either a rejection or a market order. This is not a trade, nor is it a position generated by a trade.
A trade request results in either a rejection or a market order. This is not a trade, nor is it a position generated by a trade.
- after which step, of those you listed, do you think the Trade Request Result Structure (MqlTradeResult) appears?
- According to MQL5 description:
"Structure of trade request result (MqlTradeResult)
As a response to a trade request, the trade server returns data containing the trade request processing result as a special predefined structure MqlTradeResult". and "10009 TRADE_RETCODE_DONE Order executed".
I.e. the trade server return code 10009 means that OrderSend request was successfully executed i.e. if I request data from MqlTradeResult, after receiving code 10009, how can I explain that result.price = 0 ?
Thank you:
- after which step, of those listed by you, does the structure of trade request result (MqlTradeResult) appear?
- According to MQL5 description:
"Structure of trade request result (MqlTradeResult)
As a response to a trade request, the trade server returns data containing the trade request processing result as a special predefined structure MqlTradeResult". and "10009 TRADE_RETCODE_DONE Order executed".
Hence, the return code of trade server 10009 means that OrderSend request was successfully executed i.e. if I request data from MqlTradeResult, after receiving code 10009, how can I explain that result.price = 0 ?
10009 TRADE_RETCODE_DONE - you have described it yourself - the order is executed. This is simply the fact that the order has been successfully queued to the server for execution.
Further, if this order is executed (after all, it can be rejected by the server), then there is a trade - this is the result of the trade with the opening price.
Read about
OnTradeTransaction
It is called in Expert Advisors when a TradeTransaction event occurs. The function is intended for processing the results of trade request execution.
voidOnTradeTransaction( )
const MqlTradeTransaction&trans,// structure of a trade transaction
const MqlTradeRequest&request,// request structure
const MqlTradeResult& result// structure of response
);
Nowhere have I seen the information that "This is a feature of MT5 where the result is only an order (ticket and no price) but not a trade". Kindly tell me on the basis of what information you have come to this conclusion.
Own experience.
2. If you know of any "already ready higher level (low level is hidden) developments," which allow you to get the parameters of a position immediately after its opening (code 10009 appears), without prior selection by ticket, please give an example or give a link to it.
There is another option, but it is "advanced".