![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
Hello
I know it sounds strange. When I checked the returned value of OrderSend(request,result) in previous code, I got multiple order problem. Now in my new code, I don't check the returned value of OrderSend(request,result) ( but I still assigned the returned value to some variable to avoid error on new build of the terminal.
Hi FinanceEngineer, exactly what I told you, you are just masking the real problem, since in my opinion you are printing this (###) at your previous code (the 10008 returned code), and not the break situation.
Hi Alain,
It's not clear to me what you need to know, since we are just talking about the new code of FinanceEngineer, and an advice about test the return code of OrderSend() that was changed from the original code.
Note that either his original code and his new one don't have code 10010 test, so if it's relevant to you why didn't you asked since the first post of him?
Anyway, can you explain why you would need code 10010 test for a FOK filling policy?
Since this is not the first time I see you and other Moderators talk about, do you know some cases where it's really necessary this code test for FOK (Fill Or Kill) orders, that you could share with us?
Thanks in advance.
I supposed I can also ask question on this forum, and not only always have to answer. Simply that.
We see a lot of code here, testing the returned code (MqlResult) against 10008 or 10009, but can someone explain what is the real meaning of these codes, what is the difference between "Order Placed" and "Request completed" ? As it seems it's the only 2 codes that aren't error codes, right ?
10010 is questionable, the documentation said :
10008
TRADE_RETCODE_PLACED
Order placed
10009
TRADE_RETCODE_DONE
Request completed
10010
TRADE_RETCODE_DONE_PARTIAL
Only part of the request was completed
But what does that means "Only part of the request was completed". You have noted that with FOK filling policy, that probably can't be the opening of 0.5 lot if 1 lot is requested (for example), but is it the only meaning ?
Previously you wrote about 10010 code :
I don't consider this code future proof and safe enough and this is just one example about the lack of return code, so please read again.
What can be the meaning of this sentence ? "Future proof" ? "Safe enough" for ... ? "Lack of return code", what is lacking ? (and not so important but, "read again" what ?).
I supposed I can also ask question on this forum, and not only always have to answer. Simply that.
We see a lot of code here, testing the returned code (MqlResult) against 10008 or 10009, but can someone explain what is the real meaning of these codes, what is the difference between "Order Placed" and "Request completed" ? As it seems it's the only 2 codes that aren't error codes, right ?
10010 is questionable, the documentation said :
10008
TRADE_RETCODE_PLACED
Order placed
10009
TRADE_RETCODE_DONE
Request completed
10010
TRADE_RETCODE_DONE_PARTIAL
Only part of the request was completed
But what does that means "Only part of the request was completed". You have noted that with FOK filling policy, that probably can't be the opening of 0.5 lot if 1 lot is requested (for example), but is it the only meaning ?
Previously you wrote about 10010 code :
What can be the meaning of this sentence ? "Future proof" ? "Safe enough" for ... ? "Lack of return code", what is lacking ? (and not so important but, "read again" what ?).
Just like most of people, I learnt the MQL5 coding by looking at other people's code. Strange enough to me, so far I didn't see any code checking 10010 code. However it might be worth to check. Just in case.
From what I have seen, when I check 10008 code alone, I got double entry order. And when I check 10009 code along I got double entry order. When I check both 10008 and 10009, I didn't get double entry order.
But I am just curious in terms of practical point of view, if yourself check 10010 code in your EA ? If the order was really partially completed, then what would be efficient way to deal with this kind of situation?
I probably think that most of this order sending problem might be dealt with checking volume by having PositionGetDouble(POSITION_VOLUME) inside our loop. However I am not sure practically if this is more efficient than checking 10008 or 10009 code.
If broker's server is busy, then chances of not getting right volume is as equal as chances of not getting 10008 or 10009 code.
Kind regards.
Hi Alain,
It's not clear to me what you need to know, since we are just talking about the new code of FinanceEngineer, and an advice about test the return code of OrderSend() that was changed from the original code.
Note that either his original code and his new one don't have code 10010 test, so if it's relevant to you why didn't you asked since the first post of him?
Anyway, can you explain why you would need code 10010 test for a FOK filling policy?
Since this is not the first time I see you and other Moderators talk about, do you know some cases where it's really necessary this code test for FOK (Fill Or Kill) orders, that you could share with us?
Thanks in advance.
Well, when we post on the MQL5.com forum we suppose we're talking to people who might have several types of needs while coding expert advisors... so in this case, it's obvious you can simplify everything and ask the user to code a "simpler" expert advisor, once his needs are not as "advanced" as you might imagine. However, as far as I know, there are several situations where you cannot work with the FOK filling policy.
Let me give you a very simple example: suppose you are working with stocks and the choosen volume is 10,000 stocks. Now suppose this same expert advisor works with "reversals", so at some random signal you might have to send an order to the market with a volume equal to 20,000 stocks to execute the so-called "reversal". In this case, even very liquid stocks (for instance the Brazilian heavy-weight stocks PETR4 or VALE5) might not have a bid or ask volume equal to 20,000 shares at some given moment. So in this case how would you treat this inside your expert advisor? Are you really convinced the FOK policy would be the best approach in this case? Or would you try to consider this 10010 code inside your expert advisor?
As said, when you work with small lots all the time, then the FOK filling policy could be your best solution. However, sometimes people do have more "advanced" needs...
I supposed I can also ask question on this forum, and not only always have to answer. Simply that.
We see a lot of code here, testing the returned code (MqlResult) against 10008 or 10009, but can someone explain what is the real meaning of these codes, what is the difference between "Order Placed" and "Request completed" ? As it seems it's the only 2 codes that aren't error codes, right ?
10010 is questionable, the documentation said :
10008
TRADE_RETCODE_PLACED
Order placed
10009
TRADE_RETCODE_DONE
Request completed
10010
TRADE_RETCODE_DONE_PARTIAL
Only part of the request was completed
But what does that means "Only part of the request was completed". You have noted that with FOK filling policy, that probably can't be the opening of 0.5 lot if 1 lot is requested (for example), but is it the only meaning ?
Previously you wrote about 10010 code :
What can be the meaning of this sentence ? "Future proof" ? "Safe enough" for ... ? "Lack of return code", what is lacking ? (and not so important but, "read again" what ?).
Alain, no problem, you don't have to answer, as probably you will never find a case, since this is mandatory in any good OMS protocol.
Also you don't need to talk why you didn't ask after the first post, since probably this is off-topic.
Anyway, note that FOK is an old filling policy, that MQ introduced probably to address communication with OMS, so you will find it in all good OMS protocol, like FIX, for instance (like this forum topic from year 2009, before MT5 exists).
So, in my opinion, I see no reason to ask about 10010 return code for a Fill or Kill Order, and this is the point, since this rule is mandatory and brokers and OMS providers must respect it.
Well, when we post on the MQL5.com forum we suppose we're talking to people who might have several types of needs while coding expert advisors... so in this case, it's obvious you can simplify everything and ask the user to code a "simpler" expert advisor, once his needs are not as "advanced" as you might imagine. However, as far as I know, there are several situations where you cannot work with the FOK filling policy.
Let me give you a very simple example: suppose you are working with stocks and the choosen volume is 10,000 stocks. Now suppose this same expert advisor works with "reversals", so at some random signal you might have to send an order to the market with a volume equal to 20,000 stocks to execute the so-called "reversal". In this case, even very liquid stocks (for instance the Brazilian heavy-weight stocks PETR4 or VALE5) might not have a bid or ask volume equal to 20,000 shares at some given moment. So in this case how would you treat this inside your expert advisor? Are you really convinced the FOK policy would be the best approach in this case? Or would you try to consider this 10010 code inside your expert advisor?
As said, when you work with small lots all the time, then the FOK filling policy could be your best solution. However, sometimes people do have more "advanced" needs...
The explanation is catchy. I thought the same thing as most of us probably trade less than 1 million US dollar per each trade. In highly liquidity market like Forex, partial fulfilment of order might be rare thing. However never say never. We are living in the probabilistic world. Nothing is certain. Some uptight broker might be out there splitting 1 lot into 0.5 lot. In terms of practical consideration, if some broker can't fill 1 lot any time, I will rather find another broker to trade.
Regards.
Well, when we post on the MQL5.com forum we suppose we're talking to people who might have several types of needs while coding expert advisors... so in this case, it's obvious you can simplify everything and ask the user to code a "simpler" expert advisor, once his needs are not as "advanced" as you might imagine. However, as far as I know, there are several situations where you cannot work with the FOK filling policy.
Let me give you a very simple example: suppose you are working with stocks and the choosen volume is 10,000 stocks. Now suppose this same expert advisor works with "reversals", so at some random signal you might have to send an order to the market with a volume equal to 20,000 stocks to execute the so-called "reversal". In this case, even very liquid stocks (for instance the Brazilian heavy-weight stocks PETR4 or VALE5) might not have a bid or ask volume equal to 20,000 shares at some given moment. So in this case how would you treat this inside your expert advisor? Are you really convinced the FOK policy would be the best approach in this case? Or would you try to consider this 10010 code inside your expert advisor?
As said, when you work with small lots all the time, then the FOK filling policy could be your best solution. However, sometimes people do have more "advanced" needs...
Hi Malacarne,
Sorry but this is off-topic, since as Moderators we can't confuse reality (what the user really post) and what if conditions.
In other words, if the user asks something and publish the code, and the code has the line below (as the first and old one), as Moderators our mindset must consider he is using FOK.
request.type_filling=ORDER_FILLING_FOK;
Don't you think so? If no, I think I have to revise my concepts of finding code errors and problem analysis.
Actually, if you don't use FOK, as your BM&FBovespa Brazilian cases, my mindset will change and 10010 return code must be considered, but this is absolutely off-topic, and maybe a better discussion to Portuguese Forum.
Anyway, thanks for sharing that.
The explanation is catchy. I thought the same thing as most of us probably trade less than 1 million US dollar per each trade. In highly liquidity market like Forex, partial fulfilment of order might be rare thing. However never say never. We are living in the probabilistic world. Nothing is certain. Some uptight broker might be out there splitting 1 lot into 0.5 lot. In terms of practical consideration, if some broker can't fill 1 lot any time, I will rather find another broker to trade.
Regards.
Just like most of people, I learnt the MQL5 coding by looking at other people's code. Strange enough to me, so far I didn't see any code checking 10010 code. However it might be worth to check. Just in case.
Hi Malacarne,
Sorry but this is off-topic, since as Moderators we can't confuse reality (what the user really post) and what if conditions.
In other words, if the user asks something and publish the code, and the code has the line below (as the first and old one), as Moderators our mindset must consider he is using FOK.
Don't you think so? If no, I think I have to revise my concepts of finding code errors and problem analysis.
Actually, if you don't use FOK, as your BM&FBovespa Brazilian cases, my mindset will change and 10010 return code must be considered, but this is absolutely off-topic, and maybe a better discussion to Portuguese Forum.
Anyway, thanks for sharing that.
Thanks for your opinion... It's not my intention to bring "confusion" to people's minds.
However, I don't think it's off-topic because if you don't check for the 10010 code your expert advisor could bypass this possibility and send multiple orders (totally related to the topic, don't you think?)...
That's what we're "trying" to alert since the last two posts about this same topic...