Categories
Forex Education Forex System Design

How to Determine the Size on a Historical Simulation

The simulation of a trading strategy requires a historical data series to assess the stability of the strategy’s results over time. Likewise, the strategist must consider the strategy before determining the window’s size before starting the historical simulation.

This educational article presents the concepts that will allow developers to estimate the data requirements to assess a trading strategy’s stability through a historical simulation process.

Setting the Requirements of Historical Data

As said, the strategy’s simulation process requires historical price data. Of this data, the developer must select a test window to perform the evaluation.

In this regard, in deciding the size of the historical data window, the strategy developer should consider both the statistical robustness and the relevance of the data for the trading system and the market.

However, these requirements will not accurately determine the test window’s size, either in hours, days, or even months. Instead, they provide a guideline for selecting a range of data suitable for developing the historical simulation process.

Suffice to say that the data window selection will have a significant influence on the results of a historical simulation.

Statistical Requirements

In statistical terms, the data window’s length must be large enough for the trading strategy to develop a sufficiently large number of trades to allow the strategy developer to reach meaningful conclusions about its performance. 

On the other hand, the data window should be large enough to allow sufficient degrees of freedom for the number of variables used in the trading strategy.

The standard error is a measure used in statistical analysis. The strategist can use this value as a measurement of the sample size impact in the historical simulation.

A high standard error suggests that each trade’s result is far from the strategy’s average profit. On the contrary, a low reading would indicate that the variation in an individual trade result will be closer to the average of the strategy’s benefits.

In other words, the standard error provides the strategy developer with a measure of the reliability of the average win based on the number of winning trades.

Quantifying the Required Amount of Trades 

According to the statistical theory, the larger the sample size is, the more reliable the trading strategy’s historical simulation results will be. However, several technical factors, such as data availability, avoids getting as many trades as the developer would like. 

The number of required trades increases in long-term systems, which tend to trade less frequently. In this case, the best option is to search for a sufficient amount of trades; another option is to make the data window wider.

In this regard, the statistical theory asks for a minimum sample size of 30 observations to be statistically acceptable. However, the strategy developer must aim for a much larger number of trades because the minimum of 30 samples requires the phenomenon under observation to follow a gaussian distribution, with is unlikely the financial markets would do.

Stability and Frequency of trades

The stability of a trading strategy corresponds to its results’ overall consistency during the strategy’s execution. In this way, as the strategy becomes more stable, it will tend to be more reliable over time.

The developer can distinguish the trading strategy’s stability by verifying whether the trades are distributed uniformly within the test window. Likewise, the strategist can confirm that the strategy is more stable as the standard deviation of the size and duration of the profits/losses shortens.

The frequency of trades will influence the length of the trading window. Thus, the higher the trading frequency, the shorter the historical data needed for historical simulation. 

In other words, a fast trading strategy running in markets with high volatility will require a small data window, which could reach up to three years. By contrast, a slower trading strategy, such as daily trend following, will require a larger data window, exceeding five years. 

One rule of thumb is: The strategist should make sure the trading system be tested under all market conditions, Bull, bear, sideways markets – under high, medium, and low volatility.

Conclusions

The execution of a trading strategy’s historical simulation requires a data size enough for the developer to evaluate its profitability and stability.

A high-frequency trading strategy will require less data than a long-term strategy, which will require a significant quantity of data, which could exceed three years of data.

The standard error can be used to evaluate the simulation’s results and determine the historical data window’s validity.

The strategist should ensure the trading system is tested under all market conditions: Bull, Bear, Sideways, and under all volatility types in which it is supposed will be used live.

Suggested Readings

  • Jaekle, U., Tomasini, E.; Trading Systems: A New Approach to System Development and Portfolio Optimisation; Harriman House Ltd.; 1st Edition (2009).
  • Pardo, R.; The Evaluation and Optimization of Trading Strategies; John Wiley & Sons; 2nd Edition (2008).
Categories
Forex Daily Topic Forex System Design

Understanding Slippage Effect in a Trading Strategy

Introduction

Slippage is one of the hidden costs any trading strategy is exposed to. Usually, this type of cost tends to be overlooked from studies of historical simulation. However, a strategies’ developer must understand its nature and assess its impact on its performance.

Increasing Reality in the Historical Simulation

To properly create a historical simulation of a trading system, it needs to consider certain assumptions that, although they may seem insignificant, they are not inconsequential. Their omission could lead to the accuracy of the results obtained. The most critical assumptions that the strategy developer should consider are related to the trading strategy’s deviations.

Slippage in Price and Trade

Each executed trade has a cost that occurs when it is filled. This cost is made of two parts, one fixed and another one variable. The fixed cost is known as the commission, which corresponds to a broker’s fee when it places the order into the market.

The variable element corresponds to the slippage. Slippage can have a significant impact on the profitability of the strategy. The slippage’s origin and size depend on various factors, such as the order type, size, and market liquidity.

There exist three types of orders that the strategist can place into the market; these are as follows:

  • Market Order: this is an order to buy or sell an asset at a price quoted in the current market. This order is guaranteed, but not the level at which it is finally filled. Thus, slippage may be high.
  • Stop Order:  A Stop buy Order is placed above the current price, whereas a Stop Sell order is located below the market’s price. Stop orders can be employed to enter and exit the market. The problem with Stop orders is that they usually fill at a worse price than set by the stop level. This situation occurs because when the price touches the stop level, the order changes to a market order and is executed at the first available price.
  • Limit Order: A Limit Buy order is placed below the current price, whereas a Limit Sell order should be above the current price. Unlike stop orders, Limit orders are placed to get better fills than the current market’s price. But its execution is not guaranteed. However, when they are filled, they will at the same or better price than initially established.
  • Market If Touched (MIT) Order: this type of order is a combination of the limit with a stop order. In the case of a buy trade, an MIT order is placed at a price below the current level. In the case of a sell position, an MIT order is set above the current price. The MIT order seeks a desirable price by buying at declines and selling at rallies. In turn, MIT orders seek to ensure the order is filled at a price close to where the strategy identifies a desirable entry level. However, although MIT orders combine the best of both types, they are also subject to price slippage.

Opening Gap Slippage

Markets tend to have price gaps. Usually, a price gap happens from the current close to the next day’s opening. In most cases, this gap is not large enough to significantly impact the outcome of the strategy. However, there may be larger gaps caused by significant political or economic events, while markets are closed.

These high volatility situations can lead to large slippages, particularly on pending orders. Consequently, the strategist must consider the impact of this type of slippage on historical simulation results.

Slippage by Order Size

The size of the position has a proportional impact on the slippage. In other words, as the order size increases, the possibility of a higher slippage grows, since the order gets progressively filled at worse prices. In this case, the strategy developer should design a methodology to scale in and out trades to execute the desired total size with minimal slippage.

Conclusions

The slippage is a variable cost that cannot be avoided in the real market. It may not be significant in some cases, as on long-term strategies with fewer entry and exit orders.

However, it becomes more significant in high-frequency systems, characterized by being short-term and active. In this context, the developer must consider the effect of slippage and reflect it in the historical simulation process.

Finally, the strategist should not neglect the slippage impact since its presence can considerably reduce the profits a trading strategy can generate.

Suggested Readings

  • Jaekle, U., Tomasini, E.; Trading Systems: A New Approach to System Development and Portfolio Optimisation; Harriman House Ltd.; 1st Edition (2009).
  • Pardo, R.; The Evaluation and Optimization of Trading Strategies; John Wiley & Sons; 2nd Edition (2008).
Categories
Forex Education Forex System Design

Seeking Accuracy in the Historical Simulation

Introduction

A historical simulation may seem like a simple process to perform; however, it goes beyond creating trading rules and introducing them into the simulation software. Within the software itself, some limitations can diminish the accuracy of the results and, in this way, overestimate or underestimate the possible results that the strategy would achieve in the real market.

This educational article explores the importance of precision in the simulation process and some simulation software problems.

Importance of the Accuracy 

The developing process of a trading strategy that systematically creates trades can be tested on a historical simulation procedure with relative confidence and accuracy. However, like all software, it can be affected by precision and lead to errors, which can increase, especially when looking for a historical simulation.

In this regard, the developer should not rule out a possible error in the simulation software, nor can it leave to chance the computer simulation’s lack of precision, as this may drag unpleasant results to the investor. In consequence, the developer should address the software errors in the best possible way.

The developer must seek to make the simulation as realistic as possible to address the accuracy problem. To achieve the desired accuracy, the historical data exchange must be as close as possible to real-time executions.

Thus, according to Robert Pardo (2008), achieving greater accuracy in the historical simulation will require two things: understanding software limitations and using conservative assumptions about costs and slippage in their various forms.

Software Limitations

Ignorance of historical simulation software limitations can lead the developer to a false confidence sentiment or be overly pessimistic about the historical simulation results. The most common constraints are:

Rounding of Data

The absence of the actual market price for the use of data rounding may have a cumulative effect on market entry and exit orders, which could lead to a cumulative effect, both positive and negative, on the trading strategy’s performance.

The problem of rounding in the historical simulation may lead to recording orders that, on a real market, would not have been executed or orders that would have been executed in real-time but not recorded by the simulation. A second error is a recurring understatement or overstatement in the strategy’s profits due to rounding.

The developer must determine if the historical simulation results are consistent with its real market results.

Finally, rounding errors will significantly impact a strategy that seeks small profits per trade. On the contrary, the impact will be less on those strategies that are slower or longer-term.

Price on Limit Orders

This error is a recurring problem in simulation software, and, in particular, it is presented in counter-trending strategies, which use pending orders to enter the market. In other words, the countertrend strategy places a buy limit when the market is falling and a sell limit when it is developing a rally. Contrary to a stop order, the execution of the limit order is not guaranteed.

The problem arises when the developer performs the historical simulation, and the software assumes that all limit orders will be executed during the simulation. However, according to Perry Kaufman (1995), up to 30% of all limit orders are not filled.

Faced with this problem, the strategy developer must define a security level to ensure that the order will be filled, increasing the probability of execution in the real market. This additional rule might consider that the price penetrates an additional distance to consider the order as executed.

Finally, this rule will not necessarily ensure that all limit orders will be executed; however, it will produce a more realistic approach to the simulation process.

Conclusions

The historical simulation process may present some problems generated by the code that the developer should be aware of. These inaccuracies can create false confidence by overestimating the results or drive it to be too pessimistic due to underperformance. These problems are mainly price rounding and limit-order executions.

In the first case, price rounding may induce the simulation software to execute input or output orders at levels other than those filled in the real market. To overcome this limitation, the developer must verify whether the strategy’s results are the same as the strategy would obtain in the real market.

The second error arises from counter-trend systems making use of limit orders. In this case, the developer must consider that not all limit orders are filled in the real market. Thus, the simulation could lead to overestimating the strategy’s results, creating a false optimism of the obtained performance. To mitigate this problem, the developer could introduce an additional requirement of an extra distance that the price should penetrate for the limit order to be executed.

Finally, in view that historical simulation software has limitations, the strategy developer should verify whether the simulation results are similar to those obtained in the real market.

Suggested Readings

  • Pardo, R.; The Evaluation and Optimization of Trading Strategies; John Wiley & Sons; 2nd Edition (2008).
  • Kaufman, P.J.; Smarter Trading – Improving Performance in Changing Markets; McGraw Hill; 1st Edition (1995).