Clearing the Air on Automated Trading in Forex

It has come to my attention recently that opinions on automated trading, especially in the retail Forex market, tend to consist of mixed opinions which usually results in heated discussions within the trading community. I think the main cause of these disagreements is due to the fact that everybody seems to have their own definition on what automated trading means. In today’s post, I will attempt to explain the situation as best as I can from my personal and professional perspective. At the end I will offer my own opinions on the matter.

Let’s start by first clearing up some common terms that are thrown around whenever there is a discussion over automated trading in the Forex market. This will help start everybody off on the right page so we are able to have more clarity in our dialogue.

Algorithmic trading is simply mechanical trading following a set of procedures, rules or when objective conditions are met. Algorithmic trading DOES NOT necessarily mean automated trading, since it is simply following a set of rules; you can follow and trade these rules manually or program it in code. With that being said, the automation of algorithmic trading systems hold many benefits to traders as it allows one to be able to backtest as well as optimise the system rules and parameters using historical market data.

Automated trading is the process of automating certain parts or all logic of a trading system, generally using software. Automated trading could mean something as small as setting a take profit and stop loss after a trader manually opens a new position, or it could mean automating an entire trading system that can look for entries, calculate position sizes, manage risk, exit positions, and other features required by the operator/trader. Without becoming too philosophical, discretionary trading systems simply cannot be automated.

An Expert Advisor (EA) is a proprietary file format used to program and execute automated trading supported only by the MetaTrader 4 (MT4) and MetaTrader 5 (MT5) trading platforms. Programming a trading system as an EA will allow a trader to backtest/optimise the system through MT4 and MT5’s Strategy Tester as well as execute it real-time in live markets. I see many traders using the term EA and automated trading interchangeably, which can lead to some miscommunication.

High-frequency trading (HFT), as the name suggests, is trading at high speeds that leverages high-frequency market data. Hundreds or even thousands of orders can be placed within a time span of a few seconds, with each position seeking relatively small profits. A HFT strategy is algorithmic in nature and can be considered a sub-category of algorithmic trading. HFT is almost always automated due to data processing and execution requirements.

A trading system is a set of rules or conditions that traders can use to make trading and investment decisions. These rules and/or conditions can be subjective (discretionary) and objective (mechanical). A discretionary trading system will leverage the trader’s experience, knowledge, and intuition to make trading decisions. On the other hand, a mechanical trading system will have a set of hard and quantifiable rules, and with a little effort can be written as an algorithm. “Trading system”, “trading model”, and “trading strategy” are generally terms that can be used interchangeably.

Before I dive into my opinions, I encourage you to take what I have to say with a grain of salt. My experiences and opinions will differ with yours and that is perfectly fine! Everybody is entitled to their own opinions and I hope that by sharing my perspectives we can get the ball rolling on healthy and productive discussions.

Now that we have gotten the basic terms out of the way, we can shed some light on automated trading in the Forex market. There is perhaps a general misconception in the retail Forex community that automated trading is an easy way out. What I mean by this is that I see many individuals who seem confident in that all it takes to be profitable is to purchase premade trading “robots” (usually in the form of EAs), set it on auto-pilot and watch their trading account collect profits. In reality, what ends up happening is that they spend hundreds if not thousands of their hard-earned money on EAs from various online vendors only to have it unexpectedly blow up their trading accounts; some not even making it past demo accounts. In order to keep this article short, I will forgo explaining the reasons why these commercial EAs do not perform as marketed; but if there is interest I will make sure to make another post explaining why commercial EAs fail.

This is NOT automated trading. This is just an example of how mis-informed the trading community can be.

Real automated trading can take years to understand on top of having a strong trading foundation; it requires technical skills as well as a shift in problem solving. To be an automated trader a strong mathematics, statistics, and programming background is required, alongside market and trading experience; some machine learning basics can go a long way as well. Like any business venture, it takes dedication to truly become successful. A trader needs to familiarize themselves with each step and process involved. Only then can an automated trader plan, design, prototype, backtest/optimise, execute, and manage their own automated trading systems (ATS) on their own. Only by being in control of each step along the way, will an automated trader have any real chance of becoming consistently profitable in the long run.

To summarize, automated trading done correctly can potentially yield a healthy return on investment, but effort and dedication is a must; a lazy approach will not work. Sure, there are times when an individual gets lucky and makes a quick and temporary profit trading a commercial EA, but more often than not the results are lackluster at best. I believe automated trading as a whole has been given a negative connotation because of the results of falsely marketed and over-hyped commercial EAs. Because of this, I personally refrain from associating the terms “Expert Advisor”, or “EA”, in the majority of my discussions with peers when it comes to algorithmic or automated trading. My purpose with this article is to shed some light on this hotly debated subject and hopefully offer some hope to aspiring automated traders!

With all this being said, what are your opinions on automated trading in the retail Forex market? Do you have any experiences you’d like to share? Let’s talk about them!

16 thoughts on “Clearing the Air on Automated Trading in Forex”

  1. Hi Clark,
    I wish I had stumbled upon your post earlier, hope it is not too late for a discussion 🙂
    I absolutely agree with everything you wrote and would like to add some level of complexity. When you look closer at the term trading system, many novice traders think mainly about something that creates entry signals, maybe exit, too. But under the hood there is so much more: how do you allocate your money to different symbols/markets, how do you excute your risk management (beside a simple stop loss, I am talking about a cross-portfolio risk management), how do you compare the actual trading results against the expectations generated by backtesting (or advertisement :))… the list goes on and on. the deeper you dig into the subject, the more you see how unlikely it is to get the result you wanted with a pre-defined strategy or even a black box EA.
    I am (trying to) develop my own trading system framework which is/will be open source (in case you are interested: https://www.spare-time-trading.de/en ) and because I do everything from scratch, every question I stumble upon gets my personal response which results in an unique implementation (which eventually leads to a system tailored to my personal preferences).
    Sorry for the lengthy comment, I hope you understand my point 🙂
    regards
    denis.

    1. Hi Denis,

      Could you elaborate a bit further on what you mean by “trading system framework”? Sounds very interesting.

      Thanks for sharing!

      1. Hi Clark,
        of course 🙂 At the end of 2015 I got bored doing Ichimoku-Kinko Hyo “by hand”. As you might know, it is a set of rules which basically do trend following, but moving averages that are a bit different to calculate than the western ones (at the core it doesn’t matter, it is trend following). This rule set consists of 5 different indicators, and their crossings and positions to each other constitute signals and the current market state. Not too complicated, but it takes time to do that by hand in a chart. So I thought I could automate that and started doing so. When I did the “functional break down” of what I wanted to little easy tasks I found that most of this tasks (or functions in programming terms) were not Ichimoku specific at all- so I started to generalize them. The same goes for the infastructure you need for such a program (memory handling, database set up/interfaces, statistical post processing of the generated data). So my hope is, in the not-so-distant future I will have a set of routines/functions/libraries/whateveryoucallit that will make it easy for me to implement a new idea for a trading system without doing all the (pretty boring) set up of the needed infrastructure.
        Did hat somewhat clarify what I wrote?
        Regards
        denis

        1. Looks like you’re getting there Denis! I had created a similar framework/workflow myself using a set of available tools (and some code to combine them) that made it easy for me to go from idea -> production very quickly. It was the start of my algorithmic trading career!

          Good luck!

          1. Thanks a lot! I for myself will keep following your blog! Maybe we can exchange some ideas in the future…

            Best wishes and relaxed trading!
            denis.

  2. Hi Clark,

    From my experience EA’s have to be tested a maintained as the market change, so even a very profitable ready made EA will be made obsolete after some time (usually that is that time when you purchase it).

    I could make a guess that people who make profitable EA’s after some time when the strategy stop working, they just sell it with a great back test to unsuspecting public.

    1. Hi Elia,

      You’re absolutely right. No strategy can be profitable forever since markets will change and need to be re-balanced periodically. This is the non-stationary nature of all financial markets. An edge you might have found can disappear at any time.

      In my opinion, the key is to have a strategy for different market conditions (range, trending, volatile, etc.) and be able to select the most optimal strategy given what you believe the current conditions are. Then it’s just a matter of portfolio and risk management!

  3. Not totally honest 🙂

    //+——————————————————————+
    //| Moving Average.mq4 |
    //| Copyright 2005-2014, MetaQuotes Software Corp. |
    //| http://www.mql4.com |
    //+——————————————————————+
    #property copyright “2005-2014, MetaQuotes Software Corp.”
    #property link “http://www.mql4.com”
    #property description “Moving Average sample expert advisor”

    #define MAGICMA 20131111
    //— Inputs
    input double Lots =0.1;
    input double MaximumRisk =0.02;
    input double DecreaseFactor=3;
    input int MovingPeriod =12;
    input int MovingShift =6;
    //+——————————————————————+
    //| Calculate open positions |
    //+——————————————————————+
    int CalculateCurrentOrders(string symbol)
    {
    int buys=0,sells=0;
    //—
    for(int i=0;i0) return(buys);
    else return(-sells);
    }
    //+——————————————————————+
    //| Calculate optimal lot size |
    //+——————————————————————+
    double LotsOptimized()
    {
    double lot=Lots;
    int orders=HistoryTotal(); // history orders total
    int losses=0; // number of losses orders without a break
    //— select lot size
    lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
    //— calcuulate number of losses orders without a break
    if(DecreaseFactor>0)
    {
    for(int i=orders-1;i>=0;i–)
    {
    if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
    {
    Print(“Error in history!”);
    break;
    }
    if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
    continue;
    //—
    if(OrderProfit()>0) break;
    if(OrderProfit()1)
    lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
    }
    //— return lot size
    if(lot1) return;
    //— get Moving Average
    ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
    //— sell conditions
    if(Open[1]>ma && Close[1]<ma)
    {
    res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
    return;
    }
    //— buy conditions
    if(Open[1]ma)
    {
    res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,””,MAGICMA,0,Blue);
    return;
    }
    //—
    }
    //+——————————————————————+
    //| Check for close order conditions |
    //+——————————————————————+
    void CheckForClose()
    {
    double ma;
    //— go trading only for first tiks of new bar
    if(Volume[0]>1) return;
    //— get Moving Average
    ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
    //—
    for(int i=0;ima && Close[1]<ma)
    {
    if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
    Print("OrderClose error ",GetLastError());
    }
    break;
    }
    if(OrderType()==OP_SELL)
    {
    if(Open[1]ma)
    {
    if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
    Print(“OrderClose error “,GetLastError());
    }
    break;
    }
    }
    //—
    }
    //+——————————————————————+
    //| OnTick function |
    //+——————————————————————+
    void OnTick()
    {
    //— check for history and trading
    if(Bars<100 || IsTradeAllowed()==false)
    return;
    //— calculate open orders by current symbol
    if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
    else CheckForClose();
    //—
    }
    //+——————————————————————+

    1. Hi TC,

      Perhaps not the entire code, we could start with just the entry logic. 😛

      As I assume most people would conclude to, the entry logic for a moving average strategy would be as follows (in pseudocode):

      // FastMA crossed above the SlowMA in the previous bar

      if (FastMA[1] > SlowMA[1] && FastMA[2] < = SlowMA[2]) { PlaceBuyAtOpen }

      // FastMA crossed below the SlowMA in the previous bar

      if (FastMA[1] < SlowMA[1] && FastMA[2] >= SlowMA[2]) { PlaceSellAtOpen }

      The issue with this logic is that during consolidation periods, moving averages will converge and diverge with each other several times within just a few bars. This results in the system taking several trades and paying the spread each time (as well as a small trading loss) which takes a piece out of your profits.

      This is a general characteristic of most trend following strategies; low win rates (15-30%) and high reward to risk ratios (2:1+). In trend following, the goal is to filter out these small trades, without missing out on the big winners.

  4. Hi Clark! I have been working on development of EA since february this year and I haven’t yet a stable EA which earns money permanently. I’ve tried different types of strategies, money management and cannot be sure in all of my EA prototypes. In addition I have some EA which work perfectly in strategy tester but in real demo-account tradings show awful results. I think that those who have developped something reliable don’t disclose their solutions and approaches and don’t sell their EAs))))

    1. Hello Konstantin,

      Personally, I tend to follow a workflow when developing a trading strategy. Of course, the workflow must adapt based on test-generated results as well as trading model characteristics.
      Based on what you have told me about your current progress, I would suggest a few things to investigate:

      • Micro-analysis (have you looked at each individual entry/exit generated under a microscope, and are they correct?)
      • Data quality (are you testing on reliable market data based on the scope of your trading strategy?)
      • Robustness testing (consider performing walk-forward analysis, or Monte Carlo simulation to verify robustness of model)

      Best of luck!

      Clark

  5. Good day

    My name is Kevin. I am an aspiring trader with my own discretionary trading showing promise.

    Going through all these blood sucking marketers just blinding people with their false promises of becoming a over night millionaire bull sh*t. Apologies for lashing out somewhat, but reading your blog I get the feeling you know what I mean.

    I have a passion for trading and i plan to become a day trader one day, but until then I work a day job in construction and as a result I cant be in front of my screen in the EUR and USD sessions. Hence my search for a 1m automated trading system that can scalp for pips while I analyse the market for Trends. And all I found was a inbox full of promises and reviews that screams scam!!!!!

    I have been on the lookout for someone like you that seems to know what the hell is going on with these great promises of something that sounds great and you hear all the research they did and just wow! only to find out it will end up flushing your account.

    If i look at price and apply a systematic trading system, I just cant see why it cant be programmed into an expert adviser??

    PLEASE!! can you help me understand what you mean with “Real” automated trading? I am not a programmer is it possible to have an EA to trade an account while I work? I am willing to make an effort to have this dream realized I just don’t know how..

    I hope this mail finds you well.

    Regards
    Kevin

    1. Hello Kevin,

      One of my goals for writing this post was to help new traders understand what automated trading really is, as well as seeing through the false-marketing and scams within the industry. I am glad you understand where I am coming from.
      You’ll find that as you develop rules/filters for a systematic trading system, there will be times where the rules will generate unexpected events.

      Let’s continue this conversation with an example; a simple Long-only moving average crossover strategy. Ex. FastMA “crosses above” SlowMA -> Buy, FastMA “crosses below” SlowMA -> Exit (Sell)

      How would you define this in code?

      Clark

        1. Hi Jens ten Cate,

          Before I elaborate, I’d love to see someone take a crack at it. 🙂 Please feel free to reply with your solution!

          Clark

Leave a Reply

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