Tuesday, March 18, 2014

Algorithmic Trading is becoming All the More Accessible

Algorithmic trading is becoming all the more common to the everyday investor. Companies likes Metaquotes and TradeStation provide MetaEditor and EasyLanguage, respectively, which allow traders, with a basic programming background, to create algorithmic trading strategies. Traders can add a few technical indicators to their charts, look for patterns and build a strategy to test their hypothesis.

But what if you could take it a step further? What if, instead of adding indicators to charts and looking for patterns, the algorithms themselves looked for the patterns on the chart and you decided whether it was a good opportunity or not. Sound confusing? Let’s step through an example to make it clearer. Generally, a trader brings up a chart of the asset they would like to trade and they add a few indicators. To make it easy let’s pretend the trader is looking at the EUR/USD with a 200 and a 50 period moving average. While the more discretionary traders look to see if the 50 period moving average is above or below the 200 period moving average, more sophisticated traders will export the data to Excel, MatLab, Stata, R, etc… and analyze price movements before and after crosses, on certain days, at certain times, based on the distance between the two averages, etc… They will then refine the conditions that need to be met in order to trade; this includes applying market filters like volatility or volume parameters, excluding trades during news events, or not trading on Friday afternoons. Traders then code up their strategy, select a date range, take profits and stop losses and backtest the strategy. Finally, they paper trade it (hopefully) before trading it live. If this sounds immensely time consuming, that is because it is.

What MetaTrader and TradeStation are trying to do is decrease the time it takes to code, backtest and paper trade a strategy so traders can more quickly get to the fun stuff; live trading. What more sophisticated traders, professional money managers, quantitative hedge funds and the like do is a bit different. They have access to computer scientists, mathematicians, statisticians and experienced traders. They can use intelligent algorithms to do the heavy lifting and search for patterns in the data. Instead of staring and scrolling through their charts and pouring time into Excel, Matlab, Stata and R, they allow an algorithm to do the pattern recognition for them.

Inovance Financial Technologies is creating a platform for traders to do the same analysis, but without any programming or math knowledge required. Traders input the indicators that they think influence price changes and machine learning algorithms find patterns in the data. The simple point-and-click interface allows the trader to select an asset, indicators and an intelligent algorithm and search for patterns over a specified date range. Additionally, traders can drill down into each trading opportunity to see what the patterns are before simulating or trading their strategy live. The platform doesn’t come up with a strategy for you, but it does mitigate the time a trader spends analyzing data. Traders can create an algorithmic strategy in just a few minutes. Inovance, in its private beta, offers their platform on spot FX and plans to soon expand to stocks, futures, and options.

Friday, December 6, 2013

Turning Backtesting Results into Live Profits

When building a new trading strategy we have all seen the backtests that make you sit back in your chair and think you have just conquered the world. I am talking about the nice smooth equity curves, minimal drawdowns and the perfectly timed entries and exits. Inevitably, after containing your excitement enough to actually get the strategy running live, you watch in dismay as your strategy just doesn’t perform as you expected. You are then sent back to the drawing board with a lightened bank account, a more cynical view of the world, and a deep sense of frustration. There is only word to blame for this painful lesson: Overfitting.
What is Overfitting?
Overfitting, also known as over-optimization or curve-fitting (though this last one is a misnomer as every backtested strategy has some element of curve-fitting), is tailoring your strategy to fit a particular set of data and not the underlying patterns in the market. The strategy is basically just memorizing one dataset, which is very close to useless when running the strategy live. In machine learning terms, this problem is known as the bias-variance dilemma. Bias, or underfitting, occurs when your strategy is too simplistic to ever capture the underlying signal. Variance, or overfitting, is when the strategy is really just looking at the random noise in the data and not the underlying patterns. The million-dollar question is finding the balance between the bias and variance where the strategy captures enough of the underlying signal without getting caught up in the inherent random noise.
What to do about Overfitting?
Now that you have found the culprit, what can you really do about it? There are generally three schools of thought on how to battle overfitting:
KISS: Keep It Simple, Stupid
  • The easiest way to avoid overfitting is keeping your strategy simple, as some of the best strategies are the simplest. This means simpler models, fewer inputs, less rules, and minimal filters, keeping only the most basic elements of your strategy. While this institutes a high amount of bias (underfitting), at least you can be sure your backtesting results will be comparable to what you will actually get when you run your strategy live. A simple strategy won’t usually get you the spectacular returns of something more sophisticated but it is more likely to work in a variety of market conditions.
  • More Data
  • If a sophisticated strategy is more of your style, you have to be sure you have the data to back it up. Generally speaking, using more data to build your strategy will decrease the overfitting as the model or optimization process will have more information to separate the signal from the noise. This means having years of historical data and thousands of data points to create your strategy. While you generally want to keep your strategy as simple as possible, a more sophisticated strategy does have its advantages. Just be sure you have enough data so you aren’t fitting random noise.
  • Know Your Strategy
  • All strategies are curve-fit to some extent due to their inherent nature of relying on past events to predict future behavior. The least you can do is understand the extent which your strategy is fitting the data. The best way to do is this is keeping some data separate from the training or optimization process. By running your strategy on data that your strategy has never seen, you can get a better idea of how it will perform on new data. This can help you manage expectations and know when your strategy isn’t performing as it should when running live.

  • If you are comparing multiple strategies, it is best to split your available data into 3 sets: the training set, test set, and evaluation set. The training set is used to build the strategies, the test set is used to select the best strategy, and the evaluation set is used to give you an idea of how the best strategy will perform in real life (Careful, you can only use this evaluation set once or you institute an element of overfitting by selecting the strategy that happened to perform best on that particular dataset). The general rule of thumb is 60% for the training set, 20% for the test set, and 20% for the evaluation set.

  • Knowing where your strategy lies on the bias-variance scale is crucial to understanding how it will perform in real life. It is up to you as the strategy developer to find the balance between capturing enough of the signal while filtering out the noise. Only once you understand the principles of overfitting and how to avoid it can you even start thinking about running a strategy on a live account.

    Thursday, May 9, 2013

    How to Earn a Living in Forex Without Trading

    The forex market is a notoriously risky place, yet the fast paced environment and potential for lucrative returns brings in thousands of new traders every year. For those of us who are a little more risk averse, trading isn't the only way to get in on the action. There are ways to get involved in this fast-growing industry without taking on the inherent risks that go with speculative trading.

    Affiliate Programs

    Affiliates refer clients to brokers through advertisements. Affiliates receive a commission on each referred client who opens an account. Commission is paid per referral or as a flat fee per trade. However, to become a successful affiliate you generally need a high traffic website or a large network of contacts that want to become traders. As an affiliate you are looking to refer as many clients as possible and earn a small commission from each account. (You can find a good overview of affiliate programs here.)

    Introducing Broker (IB)

    An introducing broker (IB) is one step up from an affiliate. As an IB, you would act as a middleman between the client and broker offering services such as trading tools or education to the client in return for a portion of the spread from the broker. You will have to register with the National Futures Association (NFA) and pay a $200 application fee and $750 in membership dues per year, but you are able to charge your own fees in addition to the spread. IBs frequently look for clients trading larger accounts because IBs are compensated based on the size of their clients’ orders.

    Forex Blogger

    As the retail forex industry grows and develops, there is an increasing demand for individuals experienced in the forex market. Many smaller firms are trying to establish themselves as authorities in their field through blogs and newsletters. While this assumes you are already knowledgeable in forex, many sites are looking for new writers and willing to compensate good, knowledgeable writers for their content (If only that was the case with this blog!).

    System Developer

    If you are an experienced programmer there is a large demand from individual traders looking to have their strategy coded. This may require you to learn a new programming language, such as MQL4 or EasyLanguage, but these are very similar to C based languages and are not difficult for experienced programmers to pick up. Becoming a system developer allows you to establish long-term relationships with traders and charge sizable fees for your services. You will also gain insight into trading strategies and build up a code base you could eventually use for your own investments.

    Following Signal Providers or Automated Programs

    As I mentioned in a previous article , if you have some money to invest but aren't confident in your trading abilities you can follow the trades of professional traders or automated programs. You can find traders or programs you trust and you can even diversify over a range of individuals and strategies. You will have to put in the due diligence to make sure the trader or automated program fits your investment criterion, but this can be a viable option if you want to get involved in the market without learning how to trade.

    There are many different ways to get involved in the forex market without actually trading. Whichever method you choose, you will have to spend the time becoming knowledgeable in your field, but these different options are substantially less risky than becoming a trader and could potentially be just as profitable. The forex market is an exciting fast-paced environment that shouldn't be reserved for only those risk-taking day traders or multi-million dollar institutions. 

    Come get a piece of the action.

    Thursday, May 2, 2013

    The Easiest Way to Make Money in Forex

    The forex market can be a ruthless place, destroying 90% of the traders that dare enter. Understanding the market and developing a strategy can take years and there is no guarantee you will be profitable. Luckily, in the past few years another option has emerged: let professional traders and systems handle your money while you sit back and watch. Instead of taking the time and energy to fully develop your own portfolio, you just need to find the right signals to follow. For those of us without thousands of dollars to spend on financial advisors or access to exclusive CTAs or hedge funds there are basically two options: Signal providers or automated trading programs.

    Signal Providers

    Signal providers are experienced traders who give you access to their live trades. Traders send out a signal or enter a trade that is either sent to you via email, instant message or automatically entered on your account. These signals can come from a discretionary trader or mechanical trading system and usually contain an entry price, stop loss and take profit. Some of the more popular service providers are ZuluTrade, Etoro, and ForexSignalProviders among many others.

    Advantages
    • Experience
        Signal providers allow you to follow profitable traders and analyze their performance so that you can select traders you trust and fit your investment goals.

    • Easy
        Signal providers make trading as simple as possible. You just have to wait for a signal or have the trade automatically entered on your account. It doesn’t get any easier than that.

    • Diversify
        You can choose as many signal providers as you want to diversify your trading portfolio.

    Disadvantages
    • Portfolio risk
        Though individual signal providers manage their own trades, correlations between signal providers could leave your whole portfolio at risk.

    • No backtesting
        While you can see the signal providers historical performance, you can not see how the traders would have performed in different market conditions.

    • Anonymous signal providers
        With most signal providers you know very little to nothing about them or their strategy.


    Automated Trading Programs

    Automated trading programs, as discussed in my earlier blog post, are computer programs that monitor the market and automatically enter in trades based on pre-calculated conditions. While the automated trading industry is filled with scam-like products, take my review of Fapturbo, there are viable options for investors who are looking for a little more control than blindly following a signal provider.

    Advantages
    • Emotionless trading
        One of the biggest advantages of using an automated trading program is that they aren’t subjected to feelings or emotions, the downfall of many traders.

    • Customized strategy
        You can customize your automated trading strategy to fit your individual investment style and risk tolerance.

    • Risk control
        Automated trading programs are able to measure the risk and exposure of every trade and calculate the optimal trade size.

    Disadvantages
    • Mechanical issues
        As with any computer program, there is the potential for technical issues. This ranges from power outages to program bugs.

    • Market variability
        Automated trading programs can have difficulty adapting to changing market conditions. Without a retraining or updating process, there may be periods of profitability followed by long droughts of losing money.

    • Black box issues
        Some automated trading programs are “black boxes”, where you can’t see how the trades are calculated. This can be frustrating when your program becomes unprofitable seemingly without cause.


    Whether you go with a signal provider or an automated trading program is up to you and your personal investment goals. Either of these approaches allow you to trade like a pro without investing time in developing your own strategy. However, there is still a lot of time and effort that must be put into selecting and managing your portfolio. Every hour you spend on researching and selecting your professionals will save you a lot of money and headaches down the road.

    Best of luck on your search!

    Thursday, April 25, 2013

    The Fapturbo Review: Scam or Not?

    When I first got introduced to the Forex market I was instantly intrigued by automated trading programs. The idea of a computer program automatically making trades seemed too good to be true. So hoping this wasn't a scam, I purchased what looked like the most popular program on the market, Fapturbo.

    Looking back, I am not sure what really attracted me to Fapturbo. While the thought of “1000%” returns was very appealing, the size of the scroll bar on their website should have been enough to scare me away. (For those of you who haven’t had the pleasure of visiting Fapturbo’s website, I would recommend doing so even just to see the awe-inspiring size of their homepage.)

    Even if the layout of the website wasn't enough, I did enjoy the testimonials from  “actual” customers. These collection of traders all swear by the performance, but I am guessing that if the program was able to achieve 99.96% accuracy and 10,607% profit with only 0.32% drawdown, there would be no need for Victor from Germany to give his dubbed-over “review”.

    Coming back to my experiences with actually using Fapturbo, I was almost instantly unsatisfied with my purchase. The installation process was confusing and unclear. Even looking at the settings and parameters made me want to give up and crawl back to bed. I then had the brilliant idea to reach out to the customer service hotline, surely they would help. 5 phone calls, 10 emails and 20 days later with no response, I changed my questions about the settings to asking for a full refund.

    During this time I let the program run while I tried to figure out the numerous and unexplained settings. The so-called “expert guides” were no help and only included contradicting, equally confusing information. While Fapturbo isn’t necessarily a scam; it does make automated trades in the forex market on MetaTrader 4. However, the program does not make money, the customer service is nonexistent, and they contested my refund until the very end. What more can you expect from the self-proclaimed “ultimated 100% automated Forex Money Machine”? There must be a better way.

    Thursday, April 11, 2013

    Why You Need An Automated Trading Program Working For You

    For most people the advantage of an automated trading program is obvious: people want a computer program that will make them money in their sleep. Thousands of people a year flock towards these programs with dreams of becoming a millionaire and retiring to the French Riviera with their girlfriend, but instead are left disappointed with an empty bank account. These unrealistic expectations, along with a lack of due diligence and research, have given the retail automated trading industry a bad name. However, automated trading programs offer much more than the chance to make a quick dollar.

    Building Confidence in A Strategy

    One of the biggest problems in designing a new strategy is determining how well it will perform on a live account. Having an automated trading program allows you to backtest and objectively measure your strategy’s performance. The program has clear entry signals, a set risk to reward ratio, and a predetermined trade size, which can all be optimized to fit your trading style and goals. Knowing your strategy was profitable in your backtest gives you the confidence to run your strategy on a live account.

    Developing Discipline

    Keeping your emotions in check and sticking to a strategy is one of the most difficult and important aspects of becoming a successful trader. The market is indifferent to your feelings. Trading when you’re scared, angry or just after your girlfriend has left you is a great way to lose money. Automated trading programs take the emotions out of trading, and by definition, must follow the rules of your strategy. Allowing an automated strategy to run, without your interference, will force you to become a disciplined trader. This discipline is essential to long-term success as a trader.

    Optimizing Your Strategy

    Automated trading programs give you the ability to adjust each variable of your strategy to achieve your trading goals. This could mean changing the stop loss or take profit, applying filters for certain market conditions, or even altering your entry and exit signals. In manual trading this could be an arduous and risky process filled with assumptions and guesswork. Automated trading, on the other hand, gives you the ability to conduct backtests quickly and easily with clear, objective results. Optimizing can easily turn an unprofitable strategy into a profitable one.
    Automated trading programs won’t make you a millionaire overnight nor are they a get-rich-quick scam. However, using the right program that fits your trading style will help you build confidence, optimize your strategy, and teach you the required discipline to be a successful trader. The right program is also not a bad way to make money while you’re out looking for that new girlfriend.

    Wednesday, April 3, 2013

    5 Things You Need to Know Before Running Your Expert Advisor

    MetaTrader 4 has become the most popular trading platform when it comes to forex automated trading strategies, known as expert advisors. The ability to quickly and easily build expert advisors, or EAs, attracts new traders and experienced coders alike. Within a couple hours, and with a little help from a good tutorial and a fewother examples , you can code your strategy into a working EA, run a backtest, and view the results. While MetaTrader 4 is a great way to get started, when you are building an EA for a live trading account there are some serious issues you need to be aware of.

    1. Reliability of Backtesting Results

    Great backtesting results can may give you the impression that your system is ready to go live, but it is not quite that easy. These results are completely dependent on the quality of the data used in the backtest, meaning poor data can easily lead to unreliable results. The default data in MetaTrader 4, supplied from MetaQuotes, can only achieve a modeling quality up to 90%. This may seem good enough, but this can cause huge differences in backtesting and live testing results, especially on smaller time frames . Luckily there are sources of free historical data and instructions on how to prepare the data for MetaTrader 4. Obtaining high-quality, reliable data for your backtests should be the first step in preparing an EA to trade a live account.

    2. Accurately Reflecting the Spread in Backtests

    Once you have reliable data loaded into MetaTrader4, the next important consideration is how to incorporate trading costs, or the spread, into your backtests. The spread can easily turn a profitable EA into a disaster. MetaTrader 4, by default, applies the current spread at the time of the backtest to all the simulated trades. However, spreads vary greatly and depend on your broker. A fixed spread is simply not realistic and backtesting on weekends, when the markets are closed, can lead to some interesting results. (You can view the spread used in the backtest by selecting "Symbol Properties" in the "Strategy Tester" menu.) Currently, there is no quick solution to manually set the spread that I have been able to find but please comment if you have a good workaround.

    3. Understanding your Execution Speed

    While this mainly is an issue for scalping strategies and at times of high volatility, understanding the execution speed of your trades can be crucial to building a reliable EA. MetaTrader 4 requires trading activity every 30 seconds, known as a "session". If there is no trading activity for more than 30 seconds, your session will automatically time out. This requires the IP address to be automatically be re-authenticated with login and password credentials. This takes time, ranging from 200 ms to up to 2 seconds with some brokers. Even this slight delay in times of high volatility can have a significant impact on the results of your trades. It is possible toload a script that slightly modifies, but does not actually effect your order, every 29 seconds to stop your session from timing out, which cuts out this delay. This is a great way to decrease slippage with any EA.

    4. Debugging your EA

    If you have spent any time writing a fairly complex EA in MetaTrader 4 you know the hassle of debugging the code. Most other software comes with debugging tools that allow you to easily use a break position to find problems in your code. However, MetaQuotes, the company behind the Metatrader software, caters more to the needs of brokers than traders. This leads to some features, like a debugger, not being included. Fortunately, there are a few ways to simplify your life. One option is to input print() functions into your code (the output of this print function is written to the experts/logs file). Although this can become very cumbersome, especially if you have thousands of lines of code or are not sure where your problem lies. Another option is to follow this guide and download Microsoft’s DebugView to view a neatly formatted log. There is also the option of posting your EA to the mql4 forums and hoping for a good samaritan in the forex community to help you out, but you do have to release the inner workings of your EA.

    5. Testing your Metatrader 4 Connection

    MT4 must be on and connected to your broker in order for your EA to run. There is nothing more frustrating than thinking you have an EA up and running only to see it has been disconnected and is unable to reconnect. While Metatrader 4 is programmed to automatically reconnect to the server, this does not always work as expected. If you have multiple Metatrader accounts, sometimes the wrong credentials are used during the reconnection process. Or for whatever reason there may be a connection problem with your broker or their server and you are unable to automatically reconnect. The best solution is to delete your unused accounts from the Navigator window in Metatrader 4 or include a IsConnected()command in your code to alert you if you have been disconnected. This may not be a huge problem, but can become very frustrating if you are getting disconnected and your isn't EA continuously up and running.

    Metatrader 4 may be the most popular forex automated trading software, but before running your EA on a live account there are some areas that need to be addressed. This is by no means a complete list and I strongly recommend running your EA on a demo account before setting it loose on a live account. However, if you understand these issues and the limitations of MetaTrader 4 then you are well on your way to developing a profitable and fully automated trading strategy. I would love to hear your thoughts on these or other problematic areas of MetaTrader 4. Until then, good luck and happy trading!