DSC_0049 Zach Doty Cover Photo for Successful Algo Trading

What Does Successful Algorithmic Trading Look Like?

Before we begin, you’ll notice this post deals with finance and investing, both of which are highly risky. This site and this post is strictly educational. Nothing in this post or on this website is intended as, nor should be construed as investment advice. Kindly first visit the Disclaimers page before you proceed, taking careful note of CFTC Rule 4.41 regarding hypothetical performance. Further, investing and trading is extremely risky, to the point that 90% of participants rapidly fail. As such, your participation in investing and trading could lead to loss of principal, and even further losses beyond that in some cases. Neither this site in its entirety, nor this post, nor any portion thereof, nor any resulting discussion or correspondence related to this site and post, is intended to be a recommendation to invest or trade mutual funds, stocks, commodities, options, or any other financial instrument. I will not accept any responsibility for any losses which might result from applications of ideas expressed on this site or in this post from the techniques or systems mentioned on this site or in this post. Nothing shown is the result of an actual trade. Neither past actual performance, not simulations of performance assure future results, profitable or otherwise.

Introducing this Discussion on Algo Trading Expectations

Welcome back to the journey into algorithmic trading. Hot on the heels of an introductory article dealing with algorithmic trading concepts, and a tactical discussion on algorithmic trading software platforms, we arrive at a mental and philosophical reflection point.

This endeavor into algorithmic trading is about pushing the limits of learning, and applying a broad array of market theory concepts through a scientific lens, mathematics / statistics and computer science. However, a less popular area of algorithmic trading is psychology. Yes, psychology and the mental approach to trading are real areas, even if you’re performing 100% automated, systematic and unattended algo trading.

Well-tread ground among retail traders (non-institutional, non-hedge fund traders) is the pursuit of a “holy grail”. We are bombarded by messages everywhere, in many fields of life. Buy this, use that, and your problems will vanish. Okay, perhaps that’s an oversimplification, but I think you get the point. Onward.

The Definition (and myth) of an Algo Trading “holy grail”

In both active (discretionary) trading and algorithmic trading, the “holy grail” is usually defined as a trading strategy that is has high long term profitability with consistent returns. In short, it is the ultimate trading strategy.

Spoiler alert: the “holy grail” (based on this definition) doesn’t exist. Market regimes change, trends start, trends stop, ranges form, consolidate and eventually break out into new patterns. Even Ray Dalio’s “all weather ” hedge fund strategy was arbitraged away by a changing climate in interest rates, thanks to widespread central bank intervention on the global economy.

This begs the question, is there a “holy grail”, and if so, what is it?

A New Definition of the Algo Trading “holy grail”

Here’s a new definition: The trader can be the “holy grail”.

Long term profitability with consistent returns can be a state of existence for investors and traders. Examples abound if you study the market. However, this is not due to a single algorithm or trading strategy. The trader can be his or her own secret ingredient by doing 3 things:

 

1) Understanding their portfolio of algorithmic trading strategies

2) Understanding how to effectively design, backtest and optimize trading strategies

3) Understanding when to maintain their portfolio, when to execute, modify or shut down strategies according to changing market regimes

 

Why Does This Matter in Algorithmic Trading?

We are all subject to emotions, pressure, stressors and thoughts in all we do. Even if you have a black box algo strategy which only involves you checking the account balance periodically, I can guarantee you psychology comes into play. When (not if) your system(s) enter into drawdown (read: you lose money), your head will be full of surprise, sadness, anger and so on. Even in this scenario, especially in this scenario, your management of expectations and psychology will be the true long determinant of success.

Short version: if you expect one or two algo programs to be your ticket to decades of success, you are sorely mistaken.

Wrap Up

Thanks for sticking through this brief, idealistic conversation on trading psychology and successful trading. In my next article walking through algo trading, I’ll be looking at setting up the MetaTrader4 platform for some basic tasks.

DSC_0079 Algo trading cover image by Zach Doty

MetaTrader4 (MT4) Software: A Beginner’s Algorithmic Trading Platform

Before we begin, you’ll notice this post deals with finance and investing, both of which are highly risky. This site and this post is strictly educational. Nothing in this post or on this website is intended as, nor should be construed as investment advice. Kindly first visit the Disclaimers page before you proceed, taking careful note of CFTC Rule 4.41 regarding hypothetical performance. Further, investing and trading is extremely risky, to the point that 90% of participants rapidly fail. As such, your participation in investing and trading could lead to loss of principal, and even further losses beyond that in some cases. Neither this site in its entirety, nor this post, nor any portion thereof, nor any resulting discussion or correspondence related to this site and post, is intended to be a recommendation to invest or trade mutual funds, stocks, commodities, options, or any other financial instrument. I will not accept any responsibility for any losses which might result from applications of ideas expressed on this site or in this post from the techniques or systems mentioned on this site or in this post. Nothing shown is the result of an actual trade. Neither past actual performance, not simulations of performance assure future results, profitable or otherwise.

Introduction: Why MetaTrader 4 (MT4) as a Beginning Algo Trading Platform

Alright! With the obligatory legalese out of the way, my journey into algorithmic trading and quantitative finance continues. Obviously to trade, you need to have a vehicle for doing so. Unlike the days of old where you would call a stock broker, most trading today is electronic. For many electronic trading use cases, you need:

  • A platform that at a minimum provides an electronic order management system connected to a broker
  • Who then deals with an exchange (Chicago Mercantile Exchange [CME], New York Stock Exchange [NYSE])
  • That eventually attempts to fulfill your request and back.

There are tons of software platforms and configurations which can be used to design and develop an algorithmic trading program. For the purposes of this education, MetaTrader 4 was selected as the starting platform. Though I’ve dealt with some other programs in the past such as NinjaTrader, yes, Robinhood (sigh), and TD Ameritrade’s ThinkorSwim, MT4 is the platform for this foray.

Advantages

  • Free (Obviously an important reason! Other platforms offer free trials, but with limited functionality.)
  • Free data (Close second for the most important reason. If your industry is remotely related to technology, you understand data is the new oil. While some vendors may provide free end of day data (E.g., Kinetick), what you need often has a price or cost associated with it. MT4 will offer viable free and live data, helpful to the beginner.)

For Mt4, we will get free live data from the Broker. Additionally, historical data is available from MetaQuotes and other online sources like Dukascopy.

  • Access to different markets (With some footwork, we can test and trade FX, Equities Indices, Equities (Stock), Commodities and Fixed Income instruments.
  • Ease of learning the coding language (The MQL4 language is largely based on the widespread C++ programming language. In addition to its popular base, MetaQuotes Language (MQL4) is well documented with lots of users, so many examples to learn from!)

 

Disadvantages

  • Lowest bar timeframe is 1min (If you’re doing more precise or higher frequency trading, this can be a drawback. However, A), we’re not doing HFT, B) if we were, there is a workaround. And we probably would some kind of integration with Rithmic for HFT-esque executions.)
  • Portfolio backtesting doesn’t come out of the box (If you’re simulating a multi-instrument algo strategy (Or in MT4 terms, Expert Advisor [EA]) you’ll be out of luck, and would have to test on another platform or find another methodology.)
  • Advanced statistical analysis doesn’t come out of the box either (It can be difficult to incorporate heavy statistical apparatuses in the algos. However, we can carry out statistical analysis on the data using Microsoft Excel or other statistical software (Python libraries, etc.). Performance analysis can be done using 3rd party software, more on that in the later.)

 

 

Other Possible Trading Software Platforms

 

Various reasons the above platforms listed aren’t being used includes, but not limited to:

1) Cost

2) Difficulty of learning the coding languages

3) Complicated user interfaces

4) Backtester and/or optimizer not included.

5) Software platform not well designed for building and trading algo strategies.

6) Limited access to markets

7) Poor community support and documentation

 

Why not MT5?

The main reason MT4 is being used over MT5 is because most brokers support the former but not the latter.

Some key differences between MT4 and MT5:

1) Different coding language (MQL4 vs MQL5). MQL5 is more difficult to pick up for beginners.

2) MT4 has been around longer and has better online support. There are many code libraries, templates and examples for MT4.

 

3) MT5 does not allow external data import (This is unfortunate- data management is a huge component of backtesting.)

 

Final Note: Why Forex as a Trading Instrument?

Convenience: Forex data isn’t (as) affected by many common market variables such as stock splits, futures contract roll-overs, expiries and dividends, etc. These factors can greatly complicate the testing and data cleaning process.

Data is available: Free data everywhere! Data on other instruments is much harder to obtain.

Can often extrapolate to other instruments: Algos built on forex can often be easily modified to fit CFDs on other instruments.

Principal instrument traded on MT4.

 

Wrap-Up

Thanks for tuning in- if you’re weird enough to like this, you might find my beginner’s foray into SQL interesting as well. Cheers!

Zach Doty Photograph DSC_0018

Getting Started With Algorithmic Trading

One Introduction to Quantitative Finance, via Algorithmic Trading

Before we begin, you’ll notice this post deals with finance and investing, both of which are highly risky. This site and this post is strictly educational. Nothing in this post or on this website is intended as, nor should be construed as investment advice. Kindly first visit the Disclaimers page before you proceed, taking careful note of CFTC Rule 4.41 regarding hypothetical performance. Further, investing and trading is extremely risky, to the point that 90% of participants rapidly fail. As such, your participation in investing and trading could lead to loss of principal, and even further losses beyond that in some cases. Neither this site in its entirety, nor this post, nor any portion thereof, nor any resulting discussion or correspondence related to this site and post, is intended to be a recommendation to invest or trade mutual funds, stocks, commodities, options, or any other financial instrument. I will not accept any responsibility for any losses which might result from applications of ideas expressed on this site or in this post from the techniques or systems mentioned on this site or in this post. Nothing shown is the result of an actual trade. Neither past actual performance, not simulations of performance assure future results, profitable or otherwise.

Why Am I Writing This?

Similar to my Absolute Beginning Steps for Learning SQL, I’m embarking on a number of education journeys in 2017. Another journey, seen here, is algorithmic trading. Loosely known by several monikers (below), this is an intensive field that may be both challenging and rewarding. As self-accountability and sharing, I’m posting what I learn as I progress.

 

What is Algorithmic Trading? (AKA Automated, Quantitative or Systematic Trading)

Put simply, algorithmic trading (quantitative trading) is trading financial instruments via computers, through logic, programs and preset conditions.

 

Types of Algorithmic Trading

For the purposes of this post, there are two types of algorithmic (algo) trading. 1) High frequency trading (HFT), and, 2) Low frequency trading.

High Frequency Trading (HFT): Speed is the absolute and expensive edge. Co-located servers in New York and Chicago run proprietary code on custom computer hardware, relying on fiber and microwave communications for trading movements that happen in less than a second. Having tried a variant of HFT in 2016, saying HFT is difficult is probably the understatement of the decade.

Low Frequency Algorithmic Trading: What my educational journey is going to focus on. For low frequency algorithmic trading, the trader is the edge, further demonstrated by the trading model(s) and strategy or strategies he/she designs, executes and manages.

Taking a step back, if algorithmic trading is computerized via programs and preset conditions, what main kinds of algo trading logic are out there?

Types of Algorithmic Trading Logic

  1. Macroeconomic news (Examples: Non-Farm payroll reports, FOMC policy minutes, Federal Reserve Beige Book releases)
  2. Fundamental analysis of a financial instrument (Revenues, Earnings releases, Inventory reports, Supply/demand reports, Free cash flow)
  3. Statistical Functions (Correlation, Cointegration, Mean reversion)
  4. Technical analysis of a financial instrument (Moving averages, Stochastics, Relative Strength Index (RSI))
  5. Market Microstructure (Order flow, volume profiling)

3 Core Values for Developing Algorithmic Trading Robots

  1. Market-Prudency (Ideas are fundamentally sound from a market and economic perspective.)
  2. Mathematical Models (Models and strategies are based on sound statistical methods, to maintain positive expectancy and reduce risk of drawdown and loss of capital as able.)
  3. Low Frequency (Trading frequency of the models and strategies are less than one trade per minute. Thus, the strategies do not depend on the speed or computing capacity of computer hardware and/or software.)

Goal: design and execute algorithmic trading models (robots/strategies) using basic software and hardware that average retail traders can afford.

3 Crucial Tranches of Knowledge for Successful Algorithmic Trading

  1. Tools (Trading software platforms, Brokers and execution infrastructure, Coding languages and skills, Performance analysis)
  2. Data (How to access sources, manage, cleanse and use data for algorithmic trading strategies.)
  3. Design Theory (Combining statistics, finance into focused tasks of product development and management.)

Starting Tools

As I start out on this educational journey, I’ll definitely be using the tools below, of which I have no commercial interest in. There may be more tools down the road, but that’s it for now.

  • MetaTrader 4
    • MQL4 language
  • Microsoft Excel