Can Your Trading Strategy Be Coded Into MT4 Expert Advisor?

I contacted forty MetaTrader programmers, if not more, and asked them one question.

Can any trading strategy be coded into MT4 robot?

Their answers are quite interested. Read them below.

However, what was more interesting is that only 10 of them responded. So this explains why many people tell me that it is very hard to find a good MQL4 programmer, or even the one that will respond to your request.

I appreciate and thank a lot to those who responded to my question. It tells us that all of these programmers are dedicated to their work.

Responses listed in the order they were received.

MrMetatrader - Gosta HuldenMrMetatrader

Gosta Hulden, director/programmer

Most strategies can be automated. I often get the question from clients “Is it possible to…” and more often than not the answer is “yes absolutely”. But of course there are exceptions. For example, some fundamental strategies might be more advanced than just reading a news result from a news web site and acting on it, hence it would require some manual input. But as a guide line I tell my clients; “When writing your specification, assume that anything is possible. Most of the time it will be, and if not I will let you know”. And in those cases when a strategy cannot be fully automated it is often possible to create semi-automated tools that are extremely helpful for the trader.

Barmenteros - Boris ArmenterosBoris Armenteros

Owner & Chief Programmer

From our point of view the answer is ‘YES’ in absolute terms and ‘NO’ in practical terms. ‘Yes’ in absolute terms, because trading strategies are often based on the analysis of certain variables and patterns that can be translated into MQL4. ‘No’ in practical terms, because there are some trading strategies that due to its complexity would imply a cost in time and money difficult to assume by the customer and programmer respectively.

MetaTraderProgrammer - Dynamic Programming SolutionsDynamic Programming Solutions Corp.

Zoltan Laszlo Ferenci, owner

An EA can do any trading transaction as a human can do, and it can execute strategies based on complex rules, but it has some limitation which a human doesn’t have. For example, for many years no programmer were able to develop a chess computer that won over the chess world championship. The reason was that while a computer is able to compute and compare millions of step variations and chess positions, a human thinks in strategy, and is able to change the strategy according to experiences. The latest brain science shows that the brain may change it’s own structure according to the current needs, this is never be able to be done by a computer. A trader can use an EA effectively by knowing this limitation and by using it to execute everything that can be fully automatized (saving precious time for the trader), while taking control, and change the strategy (ask the developer to alter the software) when needed.

MQL StudioMQLStudio

My answer has two parts, one theory, one practice.

MQL is a complete programming language (Turing complete, as the academics say), so any strategy that is computable can be coded as an MT4 Expert Advisor. To be computable, a strategy must be expressible as well-defined rules consisting of stored values, math operations, if-then conditionals, and looping. Subjective strategies are not computable. For example, a method that trades based on subjective interpretations of central banker arcana is not computable by machines.

Subjectivity aside, MT4 Expert Advisors are, in theory, as capable as any machine. But trading is real world, not theory. In practice, data availability and performance can make MT4 unsuitable for particular assets and strategies. For example, MT4 is not a suitable platform for a high frequency trading strategy capable of tens of thousands of trades per second. Although the logic of such a strategy could be coded as an MT4 Expert Advisor, slow performance would defeat the purpose.

Trading Coders - JamesJames

There are very few technical hurdles to overcome when programing trading strategies. On the rare occasion a client may need something outside of the normal such as having a machine read a webpage (and understanding it) or scanning Twitter for chat to see “what’s hot”. These are very complex tasks that take a great deal of specialist programming and are beyond the budget of most MT4 traders. But in general, nearly everything that people think of can be coded.

The one grey-area that catches people out is the discretionary portion of their idea. They might say “when a trend looks like ending”, which is something that a human understands as a concept but a computer cannot. A computer needs rules to be able to declare if a trend (what is a “trend”) is ending (how does it come to an “end”). You actually need a set of rules first to say what a trend is, how to measure if it is there, and then to decide how to measure if it is ending. These rules must be in the specification for the job, because a programmer cannot just adlib these rules, for if he does he is writing his own strategy, not the client’s. - PhillipPhillip

Head developer of the EA-builder

Our team at can automate any trading strategy as long as it is clearly defined by concise rules for placing, managing and closing the trades. We can also help with suggestions for improving your system or diversifying your ideas. So far we have built hundreds of EAs, from very simple ones that use 1 or 2 indicators as signal triggers to more complex strategies that do multi-instrument correlations or use artificial intelligence. News trading EAs, hedge strategies, grid systems, you name it, we’ve done it. - Shaun OvertonShaun Overton


Most traders have not boiled down their strategies to a series of if-then statements. They know what they do as a rule, but have a very difficult time expressing it. There is no limit to programming strategies if the trader overcomes the hurdle of communicating his idea. We can code anything that can be quantified with numbers.

FxCraft - Jan JablonskiFxCraft

Jan Jablonski, CEO

MT4 Expert Advisors have a lot of possibilities to code almost any strategy idea of the trader, which base on information (feed data) coming from MT4 platform. Of course, we can use all indicators which are based on historical and current feed data. There can be one problem with using historical tick data because this information is not available in MT4 platform. This problem can be resolved by collecting thick data which are coming in real time. Second thing is that we have also no access to depth of market what can be also useful in some situations.

Next thing is if the trading strategy is based on any data from other application or from other internet service, then in pure MQL (language to code MT4 Expert Advisors) it can be a problem to code such idea. But in fact it is not a big problem, because in MT4 Expert Advisors we can use external DLL files which can be created by using other (more advanced) programming language like C/C++ or C#. In DLL file we can code any connection between Expert Advisor and other application. In fact, with this possibility we are able to code any trading strategy, which will be used on MT4 platform. The only one limitation may be access to data which we would like to use.

TekArs - Richard BogosianRichard Bogosian

Senior Consultant

I believe that nearly any trading strategy can be coded into a MetaTrader4 Expert Advisor. Strategies based on High Frequency Trading (HFT) are unlikely to be effective in MT4 EAs because of the speed factor. However, strategies based sophisticated analytical methods are definitely code-able. In my own experience the more sophisticated the strategy, the more likely that it can benefit from moving complex functions into a DLL accessed from the EA.

MT4 DLL access is based on unmanaged code. Therefore, when using DLLs developed with C# or VB.NET, it is necessary to coordinate functions using a bridge. Whether coding exclusively in an EA or in conjunction with DLLs, it is helpful for clients to understand that sophisticated strategies are complex and time-consuming (even for those who know what they are doing). Clear instructions, timely response, multiple revisions are essential to the success of any project.

Emet Trading Solutions - Vadim EpsteinVadim Epstein

Emet Trading Solutions, CEO

Any trading strategy of any complexity can be coded into MT4. This may include setups based on indicators, price actions, candlestick patterns, visual manipulation of MT4 objects (like trading based on trendlines, arrows, fibos, etc.) In order to create an automated trading system, one has to have a clear set of guidelines for opening, closing and handling orders. The benefits of trading with an EA is to handle your trading with the manually unachievable speed, accuracy and frequency as well as trading non stop 24/5 a week.

Rimantas PetrauskasRimantas Petrauskas

Forex trader, programmer, author

I would like to add my answer to the same question as well. Even though I’ve created the most advanced software for currency traders on MT4, there are still things that I would not dare to program. I am not saying it’s mission impossible, but I don’t believe it can be programmed to fit everyone’s needs.

For me, things like drawing of the trend lines and divergences, is something I never dare to program. This is simply because every human being will see this differently and we all know, that computers cannot see things the same way our eyes see. Robots cannot have the same imagination. So for someone, a trendline drawn from A to B, might look inappropriate, while others would simply draw it from C to D.

Then there will be people who will never draw trend lines in those places and rather choose to draw it from E to F, etc. That’s why my Trendline Trader EA for MT4 is not fully automated, and the job to draw a trend line is left to the trader. It’s trader’s decision where and how to draw the trendline and I think you will agree that this is mostly what will dictate your success.

The same with divergence lines. I know there are indicators for that, but if you try them, you will find that they will not draw the same divergences you want to see. There will be less or more divergences.

I believe this is because human mind simply dismiss some of the trend lines or divergences because of a sixth sense, or trader’s intuition (call it any way you like).

Any feedback is welcome in the comments below.

Now tell us, what do you think. Can any trading strategy be coded into MT4 robot?

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.



  • 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

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-2017. 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.