Selecting, Managing, and Backtesting Automated Trading Strategies

Selecting, Managing, and Backtesting Automated Trading Strategies 

What is an Automated Strategy?

An automated trading strategy is a set of rules and conditions that are capable of creating and entering trading orders without human intervention. Usually, an automated-strategy refers to a software code that is designed to plug into an automated trading platform such as MetaTrader, cTrader, and NinjaTrader. An automated trading strategy basically contains three modules:

  • An analysis module that is usually based on technical analysis and market statistics
  • A decision-making module that is able to select positions and then decide position sizes (Money Management)
  • An execution module that is able to enter trading orders, and if needed, to modify or close these orders

Two Different Approaches to Automated Strategy Building

There are two main approaches for building an automated-trading strategy:

(1) Model-based strategy building

Model-strategies are based on a market theory that is attempted to fit in the market data. This type of strategy includes extended experimentation and ‘Trial and Error.’ Model-based strategies can be easily implemented as they don’t require enormous technical resources for data analysis. These are some common variables when creating a model of the market:

  • Mean Reversion
  • Market Correlations
  • Seasonality
  • Volume Clusters
  • Order Book
  • Price Patterns
  • Price Gaps 

(2) Data-driven strategy building

Data-driven strategies are based on historical market analysis and data-mining. Following the analysis of massive amounts of market data, this type of strategy aims to identify rules and recognize predictive patterns. Data-driven strategies are considerably complex and require significant technical resources for efficient data analysis.

The platform StrategyQuant may be the ideal solution for retail traders aiming to apply a data-driven strategy. StrategyQuant provides the tools of professional quants and hedge funds in order to create a portfolio of trading strategies in a quantified way. ► StrategyQuant on ForexAutomatic

The Decision-Making Module

Efficient automated strategies should incorporate a decision-making module that is capable of answering the following questions:

  1. What assets/asset classes should be traded?
  2. In what direction should these assets be traded (Long/Short)?
  3. What is the overall cost of trading (spreads, trading commissions, overnight SWAPS)?
  4. Are there any hidden risks (slippage, market correlations, etc.)?
  5. What is the optimal time to trade these assets?
  6. What is the optimal position sizing (money-management)?
  7. What types of trading orders should be used (pending orders, take-profit, stop-loss)?

The Quant Platform for Advanced Automated Forex Trading...


Basic Model-Based Automated Trading Strategies

There is a wide variety of different automated trading strategies that can be applied in the Foreign Exchange market. Many traders even combine different strategies to build a multi-trading system, capable of adapting to any market conditions.

These are some popular model-based strategies.

(1) Trend-Following Automated Strategy

A trend-following strategy aims to detect and follow strong price trends using historical data and basic technical analysis:

  1. Deciding if the market is trending or ranging
  2. Eliminating market-noise by applying a lowpass filter
  3. Recognizing Historical Support & Resistance points
  4. Trading S&R breakouts
  5. Confirming breakouts with volume bars or TA indications (MACD, etc.)
  6. Trading price and Moving Averages crossovers (i.e. 50-day or 200-day SMA)

(2) Volatility-Based Automated Strategy

There are several different automated strategies that are based solely on volatility. There can be volatility-expansion strategies, volatility-breakout strategies, and others. The volatility-expansion strategy focuses on sudden volatility changes. Price gaps can play a decisive role amid volatility expansion.

  1. Combining market volatility with price metrics (price gaps are important)
  2. TA tools that can be used include Bollinger Bands, ATR, Parabolic SAR, and etc.
  3. The strategy targets small profits but it offers a high winning percentage

(3)  Mean-Reversion Automated Strategy

The Mean-Reversion strategy is based on the statistical fact that the price reverts to its mean price, 80% of all times. In other words, 20% of all times the markets are trending, and 80% of all times they are ranging. Consequently, highs and lows create good trading opportunities, as the price is expected to return to its mean.

  1. Trading the fact that 80% of all times the price returns to its mean
  2. Calculating the mean using historical data
  3. Filtering data by applying a highpass filter
  4. Identifying a basic price range
  5. The breaking of the range may also trigger trades

(4) News-Event Algorithmic Strategy

Automated-trading can prove useful when trading the news. A simple news-event strategy may open trade positions based on the difference between actual data and market consensus. Other more sophisticated news-event strategies attempt to quantify more complex news items.

At a Glance:

  1. Quantifying scheduled/unscheduled news releases
  2. Determining the impact of news on particular markets/assets
  3. Avoiding stop-hunting techniques on major news releases

(5) Market Sentiment Automated Strategy

A market sentiment automated strategy aims to quantify the investor’s sentiment based on a wide variety of data sources such as:

  1. Fear & Greed Index
  2. COT report (lagging indicator)
  3. Options Put/Call Ratio
  4. Social Media (data-mining)
  5. Other online sentiment measures

(6) Other Automated Strategies

There are many other automated trading strategies, these are some examples:

  • Arbitrage and Statistical Arbitrage automated strategies
  • Market Cycle automated strategies (detecting the dominant market cycle)
  • Price Clusters automated strategies (Support and resistance)
  • Volume Weighted Average Price (VWAP) automated strategies
  • Time Weighted Average Price (TWAP) automated strategies


Strategy Building and Risk Management

Risk management is always an important issue for the success of every automated strategy. There are systematic and non-systematic risks, however, only systematic risk can be managed. These are the general categories of systematic risk:

  • (i) Market Risk (unfavorable price movement)

Risk Management: Position sizing (i.e. allocating less than 2% of the available capital on any position)

  • (ii) Extreme-Volatility Risk

Risk Management: Adding volatility filters and time parameters (i.e. not trading during scheduled news releases)

  • (iii) Slippage on Order Execution

Risk Management: Adding filters and trading only with real ECN brokers

  • (iv) Market Correlations (simple market correlations or Intermarket correlations)

Risk Management:: Incorporating correlation parameters based on historical data

  • (v) Software/Hardware Failures

Risk Management: Using a Virtual Private Server (VPS), and always entering a stop-loss

  • (vi) Latency (refers to time delays between requests and responses)

Risk Management: The best solution again is by using a VPS which is located close to your broker’s servers.


Strategy Building and Money Management

The key components of a money management system include position sizing and trading orders (stop-loss, take-profit, trailing stop, OCO, etc.). Nevertheless, money management is a broader concept and it may incorporate other important parameters, such as risk management.

The Kelly Formula

Introduced by John L. Kelly, this formula can calculate how much to risk on any individual trade position.

  • Optimum Size (%) = W – (1 – W) / R


  • Optimum Size (%) = percentage of capital to be put into a single trade.
  • W = The historical winning percentage of a trading system
  • R = The Historical Average Profit/Loss ratio

There is also an expanded version of the formula that appeared in Thorp’s interview in the book Hedge Fund Market Wizards:

  • F = PW - (PL / ($W / $L))


  • F = Fraction of capital to bet
  • PW = Probability of winning the bet
  • PL = Probability of losing the bet
  • $W = Dollars won if the bet is won
  • $L = Dollars lost if the bet is lost


Incorporating Extra Parameters

There are many other parameters that can be used in order to limit the risk exposure of an automated strategy.

  • Maximum drawdown (%)
  • Time parameters
  • Stopping when consecutive losers occur
  • Stop trading during news-releases
  • The maximum amount of accepted dollar losses



Backtesting Automated Strategies

Backtesting is the process of evaluating the performance of an automated strategy using historical data. Backtesting involves reconstructing trades that would have occurred during a past period by calculating results. There are several benefits that occur due to strategy backtesting:

  • Evaluating fast multiple strategies
  • Selecting among a great number of different strategies
  • Leads to Strategy optimization
  • Final verification

Key Backtesting Statistics

  • Pip value of net profit/loss
  • Max Drawdown % (measuring the maximum peak-to-trough decline during a specific period)
  • Maximum Exposure % (measuring the maximum percentage of capital allocation)
  • Win-to-loss Ratio
  • Winning/Losing streak
  • Annualized percentage returns
  • Sharpe Ratio (comparing returns with the standard deviation of those returns)


Monte Carlo Analysis

Monte Carlo refers to a set of techniques that are used for measuring uncertainty. This involves the simulation of various sources of uncertainty that are able to affect the value of a portfolio. The great advantage of the Monte Carlo method is that it can increase the dimensions of uncertainty, as the problem expands.


Advanced Backtesting with StrategyQuant

The platform StrategyQuant offers the ability to generate and backtest thousands of different entry and exit conditions, order types, and price levels, to find best performing automated strategies according to special criteria..The platform StrategyQuant offers the ability to generate and backtest thousands of different entry and exit conditions, order types, and price levels, to find best performing automated strategies according to special criteria (i.e. Return vs Drawdown, Sharpe ratio, etc.).

  • Automated backtesting based on a wide variety of parameters
  • Using randomness to test a strategy in any conditions
  • Ideal re-optimization process using 2 separate modules
  • Robustness testing

Walk-Forward Optimization

  • Monte Carlo techniques for testing the quality of automated strategies
  • Re-testing strategies for a different market or timeframe
  • Built-in walk-forward optimizer and cluster analysis tools

► StrategyQuant and the free trial


Successful Backtesting Principles

The key to successful backtesting is not to consider backtesting as an autonomous process. Backtesting is a dynamic component of a general trading process, that also includes customization and optimization of the trading strategy.

  • Combine backtesting with strategy optimization and customization
  • Perform multiple backtesting experiments covering all market conditions (trending, ranging, choppy, etc.)
  • Backtest your automated strategy over a period that includes normal and abnormal market conditions
  • Avoid over-optimization (over-optimization leads to results that are optimized for past market conditions)
  • Take into consideration volatility statistics, especially if you plan to apply high trading leverage
  • Successful backtesting can never guarantee future results (what performed well in the past may fail tomorrow)


■ Selecting, Managing, and Backtesting Automated Trading Strategies

George M. Protonotarios for (c)



  • «Building Automated Trading Strategies» -George Protonotarios (2018)
  • Generalizing the Kelly Criterion -Boyles Asset Management, LLC (2014)
  • Hedge Fund Market Wizards: How Winning Traders Win -Jack D. Schwager, Ed Seykota (2012)


Pin It