Tuesday, 21 November 2017

The Math of Algo Trading

Changing focus from discretionary trading to algo trading requires a lot of work in order to maintain and increase earnings. However, I have a lot of help from the algos to do this.

A discretionary trader may have a daily profit target of, say, $1,000 trading the ES. This may be 6 trades a day of about $45 average trade per contract. In order to duplicate or exceed this $1,000 he would need to make a number of calculations. Below is the stats to an ES algo I am creating to day trade the ES using 3 minute data. It covers a 2 year period, closing trades at the end of the RTH session, slippage and commish of $28 R/T included.



The important things to look at is the average earnings per day, number of trades, how long a trade lasts and how often the algo is in a trade and drawdown. Algos will not usually trade as often as I expect so I need quite a few of them.

The traders risk tolerance per trade then also needs to be defined.

Lets say that the available capital of our hypothetical trader is $50,000.

From all this information the trader would put together a portfolio of at least 3 algos but hopefully 6 algos or more. Looking at the frequency that each algo trades, the goal will be to maximize the use of that $50,000 so that margin is always being used. With the portfolio trader functionality available in many of the trading platforms, the number of open positions can be controlled. Even if more signals are given, the portfolio trading capabilities can stop new signals if the stipulated margin or risk has been reached until positions have been closed by the algo in its normal course of business.

In this way, we can have algos working almost 24 x 5 using the same capital while limiting risk and smoothing the equity curve due to the diversification of using a portfolio of algos.

Wednesday, 15 November 2017

This is Why I Trade Using Algos Now!

I've written in the past about how the markets have evolved to an algo impacted environment.

The fact that over 60% and perhaps 80% of the volumes of active markets are generated by algos says to me that there are a majority of volume is generated by people who think that nowadays, trading using an algo is more profitable than any other means of trading.

I've been using algos since the early days of SystemWriter,TradeStation and other software back in the 1980s. I embraced algos more as the markets became automated and orders could be input through a computer.

However, it is only recently that the technology has moved ahead to make algo trading a more viable way of trading than discretionary trading.


The chart above is a good day trading one of my DAX algos. I say "one of" because it is important to trade a PORTFOLIO OF ALGOS rather than a single algo. The strength in algo trading is the smoothing of an up-sloping equity curve due to the number of algos in the portfolio.

There is no way I would have made the trades in the above chart had I been trading manually. I don't even have to know what the logic behind the trades were. What I did have to do was to put the algo through a series of about 7 ROBUSTNESS tests before I went live. This doesn't mean that the algo makes money every day because it doesn't. There are plenty of losing days but due to the robustness testing I am confident that a llong losing period is improbable but see my disclaimer.

More posts on the "how to algo" coming.

Thursday, 9 November 2017

Discretionary or Algo: The Choice!

One of my blog readers said:


As a discretionary executor of a systematic pattern (heuristic execution of a high probability pattern)in several markets, I look at these posts with both curiousness and gratefulness.

Curious because, i do not share your inclination towards algos as you do. And grateful because you present things in a lovely, simple and undramatic fashion.

Since 2008, while I have expected discretionary trading to die...something to the contrary has happened - not just to me but 3 other folks that I know of. Our trading, has remained as straightforward as pre - 2008, while remaining completely discretionary.

While patterns have surely changed, it doesn't seem to be less profitable....just different.

What you say is quite interesting to read though, once again thank you for your efforts in making these posts public. They are very illuminating and thoughtful.


I tend to agree. The markets are very different but can still be traded profitably if you know how.



BUT, and there is a big "but", you need to be in front of your workstation for hours to catch the trade(s) that suddenly appear. Markets trade more in swings separated by quieter periods so if you are not there and focused you can miss the trade of the day. Also, covering more than one market at a time is more difficult.


However, there is a better reason for trading algo: capital utilization. If someone has trading capital of, say, $50,000 and is trading as a discretionary trader, they may trade, say, the ES and risk $1,500 a trade. The number of contracts would be related to the risk.


As an algo trader with $50,000, I don't have to sit there, I can trade 23 hours a day but more importantly, I can trade 6 markets each risking $1,500 per trade as the metrics of the portfolio I am trading show me that due to that diversification, my risk allows that. Out of the 6 or 7 markets I will probably only have 2 trades open at the same time. In fact, I can design my algos with that in mind.

Yesterday, my flobot traded the DAX like this:




As you can see, this is quite active trading using 18 minute bars with relatively tight stops.

Wednesday, 8 November 2017

How I Create Algos that Make Me Money!

The question to ask is: " Do algos make money"? Nothing else matters. Either algos make money or they are just another computer game!

This post will show the steps I take to create a profitable algo. Subsequent posts will go on to talk about taking a number of algos and making them into a portfolio as I have indicated in a previous post.

My starting point is to download data for use in one of the applications that can mine the data and create automated trading algorithms without me needing to be a programmer. These programs can take the granular data and create bar sizes through which it sorts to find the optimum bar sizes.

Next, I take my algo creation program and configure it to find the results I want. It's like reverse engineering an algo. I specify the profitability, draw down, percentage profitability, profit factor and a host of other metrics. The Program then mines the data and come up with a few thousand algos from which to choose.


The chart above shows the results of one such equity curve from a data mining effort. The chart breaks the result into 3 sections. 60% of the data was used to train the algo - to find what is profitable. The second section is the result of testing that algo against data that was NOT used in training it. Finally, the third part of the chart shows what would have happened if I had then run that algo in the market.

I pick the equity curves that look the best. The one below is one of the best I've ever created.


The big issue with data mining is curve fitting. Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points

Looking at the metrics that the data mining application puts out allows me to avoid a lot of the curve fitting. I then also run a Monte Carlo Analysis that changes many of the metrics that a selected algo has output so that I can see whether it is too curve fitted and whether it is likely to be robust. The Monte Carlo analysis provides a report as below.


This alone could be enough. However, I also have a program that can do a FURTHER walk forward analysis. The picture below shows a set of results I like of that WFA.


The bottom lines of the chart above show the ongoing re optimization schedule.


As you can see, changing inputs and then looking at the results on unseen data afterwards shows that the algo was pretty robust and profitable. Of course there is an important disclaimer that you should read at the bottom of the blog page. However, my aspiration is that in live trading I achieve between 25% and 50% of the results shown.

Monday, 6 November 2017

Trading with Algos: Where to Start

The title of this blog post reflects the issue that most traders have if they have yet not started using algos to trade. I say "yet" because I believe the switch to algos from discretionary will become almost inevitable for most traders.

Having made such a bold statement, let me show why I believe it to be true.
  1. The markets are trading more in fits and bursts. The rhythms have changed. There are more periods of inactivity and this makes it harder to maintain focus. Easy to miss the trade of the day.
  2. Active periods can now be at anytime within the 24 hour clock. A trader doesn't and can't spend 24 hours at his workstation so as not to miss the trade of the day.
  3. A very high percentage of daily volumes of most active markets are generated by algos. Not only are other traders' algos your competition by they create the noise that makes it harder for a discretionary trader to trade.
  4. Different markets are active on different days. A trader needs to be watching a number of markets at the same time to catch the trades to make a living.
       ..........and the list goes on.

Getting back to the title of this blog post, where does one start?

If you are a coder, you can "think up" a trading system and code it. You need two skills for that: trader and coder. Not easy but doable over time. Lots of false starts and lots of time needed. Your choice here is whether to start from scratch or use a platform such as NinjaTrader, MultiCharts or the likes.

If you're not a coder then you have different options.
  • Are you an experienced trader that already has a system and can get it coded by someone for one of the platforms? This can be quite a difficult and expensive option. Firstly, defining the strategy for someone else is not that easy. Secondly, you are spending money on something that probably won't be profitable (I say this from experience). One good option here is to buy programs from Sharkindicators that alows a non coder to create a trading system. This is a viable solution if you have a trading system that you want to automate.
  • You have no idea of what a robust (going forward) strategy should be even though you can trade as a discretionary trader. The algo has rules not discretion. In this case you can either buy an algo that is commercially available or you can use one of the several applications available can create and test trading systems without you needing to know how to code. I'll post soon on this topic as its a big one.

Saturday, 28 October 2017

Blog is 8 Years Old

This blog is now 8 years old.

Looking back, nothing has changed and everything has changed.

The "nothing has changed" is that the markets are still a challenge for most people to trade profitably.

The "everything has changed" is a lot.

Firstly, we have had the pits disappear. Then we had the electronic traders take over and we began trader to trader rather than trader to local and then local to trader. The next evolution was algo traders including HFTs.

We now find that the markets are probably 80% to 90% traded by algorithms in some way or another as far as volume is concerned.

I'll say it again: 80% to 90% of volume is generated in some way by algorithms.

The question we need to ask ourselves is who is making the money out of trading. Is it most of the algorithms or is it to relatively few discretionary or partly rule based manual traders?

Lets look at another phenomenon. The markets are now more "barbell like" than ever before. I rely a lot on the more recent work of Peter Steidlmayer of Market Profile fame for these conclusions. Let me explain.
The areas of accumulation and of distribution are the higher volume areas. While this has always been the case, the "distance" between these higher volume nodes has reduced considerably. This is due to the fact that volume data is available "live" as it happens and the algos can read that volume. This enables the algos to react to smaller and smaller profits and losses.

Another thing worth mentioning is that volatility changes happen differently to the way they did before, both intra day and inter day.

Another idiosyncrasy is that there are periods when the algos "rest" - the market becomes quieter with lower volumes. Then, suddenly, activity comes back and there is a sudden move.This likely because the algos have decided that there are open positions that they can take advantage of with their particular strategy.  



Subsequent posts will talk about how I fit into the way the markets are now.

Wednesday, 25 October 2017

A Murder of Crows

A Murder of Crows is what a flock of crows is called. I trade a portfolio of algorithms and have been looking for a name to describe such a portfolio. In fact, I have more than just one portfolio of algorithms.

Why do I trade portfolios of algorithms you ask. Well. look at the pic below:


This is Market System Analyzer from Adatrade. The graph shows a combination of the day by day P&L of one of the portfolios. The portfolio is comprised of 18 different markets. By trading the 18 different algos as a portfolio I smooth out the equity curve and better utilize my capital.

Not all algos are in a position at the same time. By a more calculated use of capital my annual return is much, much higher. Maximize profits and minimize drawdowns.

The above porfolio is constructed on daily data. I have others based on intra day data.

Portfolios can be constructed on as few as 3 markets although I must say, "the more markets the better".