Guide to trading system development

The continuing evolution of technical analysis software has simplified the creation of computer-automated trading systems. Some systems just generate the signals for the trader to follow, while others place the trades into the market on behalf of the trader. However, being able to program your favorite trading platform is just the beginning. You must have a framework for testing your trading theories to be sure that profitable backtests are not merely because of luck, but are the results of robust modeling of a market’s behavior.

This series of articles will present a simplified approach to developing a trading system for the retail forex market. The system development tool we’ll use will be MetaTrader 4 (MT4), although the ideas and process presented apply to a wide range of software platforms. The methodology will cover general concepts targeted to the beginning system trader. When we take shortcuts for expediency, we’ll refer the reader to additional resources for more in-depth information.

There are five distinct phases in trading system development:

Phase 1: Developing the market model and the basic automated system — the basic automated system implements this model but does not incorporate stop losses or profit targets. The basic system is for the sole purpose of collecting data for statistical analysis used in the later development phases.

Phase 2: Risk management — the initial stop loss (ISL). Using the data gathered in Phase 1 and based on the statistical analysis of that data, we add an ISL to the trading strategy. We use optimization to find a stop loss parameter that suits our needs. We will use walk-forward analysis to test this version of the system.

Phase 3: Profit management — the profit target (PT). As in Phase 2, we will use the statistical analysis of our data to incorporate a profit target into the system. Again, we will use optimization to find an appropriate profit target and then use walk-forward analysis to test this version of the system.

Phase 4: Money management — the trade size algorithm (TSA). This phase does not depend on the data collected in Phase 1. Instead, we will incorporate the popular fixed-fraction trade size method to determine how many lots are allocated to each trade. Popular trade literature is replete with advice to restrict per-trade risk within a range from 1% to 3% of account equity. We will run our optimization using those percentages, and then once again use walk-forward analysis to test this version of the system.

Taken together, Phases 2 through 4 comprise trade management, but there is one more critical step:

Phase 5: Monte Carlo analysis — many traders stop after Phase 4. However, our testing is not complete at that juncture and the system is not ready for deployment (assuming it is profitable). Despite our walk-forward analysis, we cannot be sure that our results are not because of luck. In other words, our model may not describe market behavior accurately; favorable results may have benefited from a market environment whose price action just happened to coincide with our logic. Monte Carlo analysis will help determine whether our model was successful because of luck (randomness) or its ability to identify and exploit a real market pattern.