How does a trading system work?

A trading system - also called a strategy - exploits market inefficiencies for predicting price trends of financial assets. In a perfect, efficient market, prices would only be affected by real events, such as the publication of company results. All traders are 'informed', decide rationally and act immediately. The price curves in such a hypothetical market would be pure random-walk curves that contain no information for predicting future prices.

Fortunately for trading strategies, real markets are far from this theoretical ideal. Market inefficiencies are everywhere. They are caused by slow reaction on news, incomplete information, rumors, and irrational trading behavior (such as following advices by trading gurus). Any inefficiency can allow a strategy to predict a small part of the price curve with some degree of accuracy. However, there's a problem: Aside from the most obvious inefficiencies, such effects in price curves are not visible to the human eye.

Look at the chart below:

One of the two lines in the above chart is the EUR price in US$, the other one is a meaningless curve from random numbers (you can produce such curves with the Zorro script RandomPrice). Can you tell which price curve is real? In studies, even 'expert traders' and analysts* were unable to distinguish between real prices and random numbers. But a simple computer program has no problems with that. Prices don't walk randomly; their inefficiencies can be easily detected by analyzing price curves under many different aspects.

A famous deviation from the random walk is visible in the price movement analysis below:
 

In the chart, the height of the bars is equivalent to the number of series of rising or falling prices. The red bars are from the real EUR/USD price curve above, the blue bars from a curve of random numbers. The numbers on the x axis are the duration of a price movement in hours, at the right side for rising, and at the left side for falling prices. For instance, the "3" at the right means that the price was rising for 3 hours in sequence. The height of a bar indicates how frequently such a rising or falling series occurs in the curve. If prices would move totally random, the red bars had the same heights as the blue bars. We can see that this is not the case: rising/falling series of 3, 4, 5, or more hours occur more often in the red price curve than in the blue random data. 1-hour series - a price rising in the first and falling in the second hour, or vice versa - occur less often. Prices tend to keep their direction: that's the famous "fat tail" of price distributions. This effect exists with almost all assets and time frames; it can be used for detecting if a price curve contains real prices or just random numbers. You can generate such price movement distribution charts with the simple script RandomWalk - just experiment with different assets and bar periods!

Another effect - a real inefficiency that can be exploited in strategies - is visible in the following spectral analysis chart:

It displays the amplitudes of regular cycles found in the S&P 500 price curve in January 2013. The x axis is the cycle duration in hours. As you can see, the highest peak is a cycle of about 24 hours, some minor peaks are at 36, 54, and 64 hours, and a broad peak at 120 hours, equivalent to a weekly cycle (a week is 5 days x 24 hours, as weekends are skipped in price curves). Cycles arise from synchronized trading behavior and are not necessarily aligned to days or weeks. Those cycles are not found in random data, at least not when the data sample has sufficient size. They are also normally not visible to the naked eye in price curves, but they can be detected with spectral analysis (you can use the Spectrum script for this) and exploited for generating profit in automated strategies. You can find an example for cycle based trading in the tutorial. A similar trade method is used in Zorro's Z2 strategy.

Often, temporary price patterns establish and can be used by intelligent algorithms for predicting short-term trends. The following curve is produced by a 'deep learning' neural net structure:

The net was fed with EUR/USD price changes of the last 60-minutes bars, and predicted the price direction of the next hour. The blue curve shows the accumulated correct predictions minus the wrong predictions from a walk-forward analysis. The price direction was predicted with 57% average accuracy. The net was re-trained every 4 weeks, as the patterns began to lose their predictive power after that time. We can see that some short-term predictive patterns pop up almost all the time in the market. Such patterns can not be found in random data - a prediction curve had no clear direction in such a case.

Another interesting inefficiency can be seen in the following price distribution:

In the chart, the height of a bar is equivalent to how often a certain price appears in the price curve. The red bars are based on the EUR price in Swiss Francs (EUR/CHF) from October 2011 up to January 2015; the green bars are the EUR price in US Dollars (EUR/USD) in the same time period. You can generate such a chart with the Distribution script. We can see that the red EUR/CHF price distribution is quite narrow and ends abruptly on the left, as if cut with a knife. In contrast, the green EUR/USD price distribution is much wider with a broad peak in the middle. It resembles a bell curve (more or less), which indicates a random price distribution. The EUR/CHF distribution however is no bell curve. It reveals a market inefficiency that can generate profit in automated trading. In this case, the inefficiency is the result of the CHF price ceiling that was established by the Swiss National Bank from September 2011 until January 2015. It prevented the EUR from dropping below 1.20 CHF. This kind of market inefficiencies can be very successfully exploited by grid trading strategies.

---------------------------------
* The difference between an expert trader and a beginner is that the former has lost more money.

Designing trade strategies

Highly profitable strategies are often astoundingly simple, but properly developing them is not this easy - otherwise anyone would be doing it. At first you should have some basic knowledge of the financial assets that you want to trade. Second, you must be able to describe trade entry and exit conditions in a precise language. Without being able to read and write script code, you can never seriously develop and test a trading system. And third, you must be aware of all the subtle statistical effects that can cause different outcomes of test and real trading, and know how to deal with them. All this is described in this manual and in the tutorial, and after learning it you have the basic knowledge for developing own strategies.

Once you got the basics, you can develop your own systems. The general process of designing a trade strategy is described here: Build better strategies: The development process. For going deeper into the matter, check out the links.

One thing is certain: the future is unknown. When you develop a strategy, you use historical price data for testing and optimizing. But when you trade it, prices are real. The market and its inefficiencies can undergo changes of any kind. What worked in the past is not guaranteed to work in the future. Therefore, even when you're using proven systems such as the Z strategies, you always deal with an element of uncertainty. For not relying completely on your luck, learn as much as you can and develop as many different strategies as possible.

See also:

Trading 101, Strategy Workshops, Indicators, Tips&Tricks, Links