Can Your Trading Strategy Be Coded Into MT4 Expert Advisor?

MQL4 cartoon programmer

Guest post by 4xdev.

Want to know if you can code your trading strategy into MetaTrader 4 robot effectively?

Read on to find out more!

One of the most capable features of MetaTrader 4 is algorithmic trading (automated trading) which lets you develop, experiment, and apply Expert Advisors and technical indicators. Additionally, it removes any complications in methodical and trading action.

On this platform, you will find the MQL4 IDE (Integrated Development Environment) which can allow you to develop trading bots as it has an MQL4 object-oriented programming language core to develop trading strategies. It is very efficient, flexible, and functions at a distinctive level. It sports a debugger and lets you compilation via the editor. Once you have done that, it automatically moves your application to MetaTrader 4 where a test or optimization is run on it in one of the MQL4 IDE components, the Strategy tester.

Explaining further, this means that the MetaTrader 4 make the broadest chances for the development of Expert Advisors and technical indicators open to you. Aside from that, you will get extra services that let you put your programming skills in play when using MetaTrader 4. 

Can any trading strategy be coded into MetaTrader 4?

The question we frequently receive from our clients is if any strategy can be coded into MetaTrader 4. This part of the article will provide a comprehensive answer to the question and clear the doubts you may be having. So, if you’re one of those who ask such questions, follow us as we explain this in detail:


On the MT4, you can code any trading strategy regardless of its complexity thought it will encompass various setups as related to indicators, price actions, candlestick patterns, visual manipulation of MT4 objects, e.g. trading based on trendlines, arrows, fibos and more.

You must possess a clear set of guidelines for opening, closing, and handling orders if you wish to generate an automated trading system. The advantages of using an EA to do your trades include being able to handle your trading with the physically unfeasible swiftness, precision, and frequency as well as carrying out your trades continually 24/5 a week. 


Despite the fact that you can precisely code any strategy in Meta Trader4, some exceptions still exist. For instance, several basic strategies might be more sophisticated than just reading a news result from a news web site and acting on it, therefore it would need some physical input.

Nevertheless, you can code strategies based on complicated analytical methods. From our own research or encounter, we have found out that with an increase in the sophistication of the strategy, the more likely that it would be able to gain from moving intricate functions into a DLL accessed from the EA.

Hence, it is in most cases but if not, we will inform you too. And in those situations when it cannot completely automate, it is often likely that you can create semi-automatic tools that are very useful for the trade.

Wrapping UP

Although most trading strategies can be encoded in an MT4 Expert Advisor, some of them may contain features not supported by the platform. At 4xdev, we always warn the customer whether it is possible to implement the strategy or whether it is necessary to make changes to the specification, abandon some features, or change them.

To understand whether it is possible to implement a particular strategy, we need a description from which it is possible to select a set of rules that can be implemented programmatically for the strategy.

In terms of performance, almost any strategy can be created, but not everyone will work fast. For example, an advisor that will check all currency pairs will work much slower than several identical advisors working on the same currency pair.

For specific tasks that are beyond the scope of MQL capabilities, we can use third-party libraries that will add all the necessary functionality to the MT4 Expert Advisor.

The 4xdev team has extensive experience in creating tools for MT4 (more than 500 orders for MT) and will certainly cope with a project of any complexity.

Click the get a quote button to contact us for your project needs.

About the author

Rimantas Petrauskas

First I am a father, a husband and then the author of the book “How to Start Your Own Forex Signals Service”. I am also a Forex trader, a programmer, an entrepreneur, and the founder of Forex blog. I have created two of the most popular trade copiers and other trading tools for MT4 that are already used world wide by hundreds of currency traders.


Leave a comment
  • Great compilation of replies and minds Rimantas.

    Very interesting question also. As fas as I can see MT4 has so many limitations compared to the human mind.

    One good example of this is I have always wanted live dynamic calcs, but MT4 purely mostly functions on ‘tick’, and not milli/micro second calcs between ticks, mostly leading to intense CPU drain. Then you have bridging, server side handling etc.

    The currency market is now so HFT based from ‘the big guns’, a lagging platform like Meta simply doesn’t stand a chance from what I can see. My only solution to deal with this, is draw down which no retail trader can avoid from the second a position is opened.

    • Thanks for your feedback, Conway. MT4 does have lots of limitations for sure, but still I cannot complain about it that much at the level I need it. I think the same goes for many traders.

      As for HFT and other things you mention, I agree. And draw downs really sucks, but I see that as a part of the trading plan.

      Good luck with your trading 😉

  • Great article Rimantas, many thanks!

    I’ve been thinking about forex robots a lot lately as I’ve had periods when I’ve just been too busy to sit in front of the charts for several hours. And as I said once in a post “nothing beats the feeling of making money while you sleep!”

    I agree with your comment about trend lines, as an example of what can’t be coded well. Another one that I’ve always thought would be impossible is Fibonacci, for the reason that the decision to select points A and B to draw the fibs between is such an arbitrary one, even if we try to define it beforehand.



    • Erron, I agree with you on Fibonacci. You can definitely program EA to use it, but still, EA will not see and choose Fibo levels the way individuals see and feel.
      Thanks for your comment.

  • Interesting. I’d like to get a handle on trading the strategy that I’m learning at present and in future perhaps take the time to code it if possible…

  • Rimantas, I agree with you regarding subjective conditions such as trendlines. Tom DeMark is quite good at establishing rules on how they should be drawn (between two pivot points). For a high point, a pivot occurs when x number of highs to the left and right of the pivot are all lower than the pivot; the reverse is true for a low point. Too many traders draw subjective lines that tend to reinforce what they want to believe. One of the more difficult issues to address when programming for clients is to get them to understand the importance of specific, objective conditions.

    That doesn’t mean that everyone has to use DeMark’s methods. It just means that they need a consistent, clearly defined method. That true for all aspects of trading strategy development. A programmer should be able help clients to identify methods when needed. That’s part of the added value of hiring an experienced programmer who also trades.

  • “Can any trading strategy be coded into MT4 robot?”
    If that trading strategy can be successfully demonstrated/shown on MT4/MT5 manually, then it can be coded using MQL4 /MQL5.
    Any hybrid strategy (which requires human input) can be coded.
    A trading strategy which can be fully automated may not have a good return in future,
    The problem is not in coding, but in thinking out the algorithm properly.

    Of-course we *cannot* do HFT using MT4.

  • Hi, this might be a stupid question, but can an expert advisor encrypted with virus/ malware by any chance? If I “install” an EA from an unknown source will my computer/ MT4 account be compromised?

    Thank you very much in advance to answer this noob question.



    • Hi, if EA is using external DLL library, then yes, it is technically possible. But I never heard of such case yet in 7 years of my MQL4 programming career.
      And if you run EA that does not use DLL, or you have it disabled for that EA, in such case there is no way to install any malware on your computer.

      Hope this helps.

Leave a Reply to Haroun Cancel Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Copyright © 2009-2020. Rimantas Petrauskas | Terms and ConditionsPrivacy PolicyEarnings Disclaimer
Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts.
The purchase, sale or advice regarding a currency can only be performed by a licensed Broker/Dealer. Neither us, nor our affiliates or associates involved in the production and maintenance of these products or this site, is a registered Broker/Dealer or Investment Advisor in any State or Federally-sanctioned jurisdiction. All purchasers of products referenced at this site are encouraged to consult with a licensed representative of their choice regarding any particular trade or trading strategy. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this website. The past performance of any trading system or methodology is not necessarily indicative of future results.
Clearly understand this: Information contained in this product are not an invitation to trade any specific investments. Trading requires risking money in pursuit of future gain. That is your decision. Do not risk any money you cannot afford to lose. This document does not take into account your own individual financial and personal circumstances. It is intended for educational purposes only and NOT as individual investment advice. Do not act on this without advice from your investment professional, who will verify what is suitable for your particular needs & circumstances. Failure to seek detailed professional personally tailored advice prior to acting could lead to you acting contrary to your own best interests & could lead to losses of capital.

Copyright © 2009-2021. Rimantas Petrauskas | Terms and Conditions | Privacy Policy | Earnings Disclaimer
Malcare WordPress Security