![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
Introduction
If you are reading this article, probably you are facing the issue that your expert advisors are not working in some brokers. Speciffically you could be facing the Message Error Invalid Filling Mode or Unsuported Filling Mode. If this is your problem you are reading the right article on MQL5 community.
This issue is becouse there is, at least at the time i am writting this article, two options to set the filling mode of your trades : SYMBOL_FILLING_FOK or SYMBOL_FILLING_IOC. If you want more details about this two filling policies you can review the documentation about them here. Some of the brokers accept IOC policy or FOK policy but you never will know in advance, at least if you know too well all the brokers in the world, the type of filling policy your End User (a.k.a the user of the expert advisor) will face. So the main idea of this article is to show a simple and manual approach to solve the issue of the unsupported filling mode in yor developements and saving you a headache, and long search on stackoverflow, to solve this issue.
The code
On the web there is available a lot of solutions for this issue but some of them are too advanced for a noob like me, so i decided to take an easier and simple approach to deal with this issue.
This approach consist on let to the end user of the expert advisor set the filling mode of the trades the expert advisor will perform, like a switch that you can turn on or turn off. Given this, the first i did was to set an input string that can take two values "IOC" or "FOC"
Then, the next step is to build the trade request using the variable typeoffilling in an if statement. So if this variable is set "IOC" then we will create a trade request with the filling policy IOC and in any other case, we will create a trade request with the filling policy FOK as it is shown in the nexts lines of codes:
The full code, at least the OnTick() function, should reensamble something like this
Conclusion
This short article shows a simple way to make your expert advisor work on any broker you can have. Yes this solution is a simple one and is not automated wich requires that your End User knows something about the filling policy and will put you a little extra job to create some instructions. Also this approach could be extremely hard to implement if your code is too complex.
Hope this small article helps you on becoming a great Algorithmic trader
Disclaimer
The code above is only for educational purposes. The author of this article is not responsible for the use of this code on real accounts.