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 Daily Topic Forex System Design

Designing a Trading Strategy – Part 5

Introduction

In a previous article, we presented the effect of incorporating additional rules in a trading strategy during the design process. In particular, we intuitively proposed a rule that opens a position using a size considering a percentage level of equity in the trading account.

In this educational article, corresponding to the last part of the series dedicated to designing trading strategies, we will expand position sizing concepts.

Position Sizing

The determination of the position size in each trade corresponds to the third element of a trading strategy. This decision will determine the capital that the investor will risk in each trade.

The position sizing corresponds to the volume committed in each trade. This volume can be the number of contracts, shares, lots, or another unit associated with the asset to be traded. The complexity of the position sizing is based on the efficient determination of the position to ensure maximum profitability with an acceptable risk level for the investor.

Programming the Position Sizing

To visualize the difference between some methods of position sizing, we will apply the criteria to the strategy of crossing moving averages analyzed in previous articles:

Fixed Size: This method is probably the most typical when developing a trading strategy. The rule consists of applying a fixed volume per trade. For example, consider the position size of 0.1 lot per trade, the code for our strategy is as follows:

extern double TradeSize = 0.1;

   //Open Buy Order, instant signal is tested first
   if(Cross(0, iMA(NULL, PERIOD_CURRENT, Period1, 0, MODE_LWMA, PRICE_CLOSE, 0) >
 iMA(NULL, PERIOD_CURRENT, Period2, 0, MODE_SMA, PRICE_CLOSE, 0))
 //Moving Average crosses above Moving Average
   )
     {
      RefreshRates();
      price = Ask;
      SL = SL_Pips * myPoint; //Stop Loss = value in points (relative to price)   
      if(IsTradeAllowed())
        {
         ticket = myOrderSend(OP_BUY, price, TradeSize, "");
         if(ticket <= 0) return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
      myOrderModifyRel(ticket, SL, 0);
     }
   
   //Open Sell Order, instant signal is tested first
   if(Cross(1, iMA(NULL, PERIOD_CURRENT, Period1, 0, MODE_LWMA, PRICE_CLOSE, 0) <
 iMA(NULL, PERIOD_CURRENT, Period2, 0, MODE_SMA, PRICE_CLOSE, 0))
 //Moving Average crosses below Moving Average
   )
     {
      RefreshRates();
      price = Bid;
      SL = SL_Pips * myPoint; //Stop Loss = value in points (relative to price)   
      if(IsTradeAllowed())
        {
         ticket = myOrderSend(OP_SELL, price, TradeSize, "");
         if(ticket <= 0) return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
      myOrderModifyRel(ticket, SL, 0);

Percentage of Risk per Trade: this criterion considers the account’s size given the account’s capital and estimates the stop loss distance needed to execute the trade according to the devised strategy. The common practice is to risk 1% of the equity currently available in the trading account. In this case, the implementation of the strategy is as follows:

double MM_Percent = 1;
double MM_Size(double SL) //Risk % per trade, SL = relative Stop Loss to
 calculate risk
  {
   double MaxLot = MarketInfo(Symbol(), MODE_MAXLOT);
   double MinLot = MarketInfo(Symbol(), MODE_MINLOT);
   double tickvalue = MarketInfo(Symbol(), MODE_TICKVALUE);
   double ticksize = MarketInfo(Symbol(), MODE_TICKSIZE);
   double lots = MM_Percent * 1.0 / 100 * AccountBalance() /
 (SL / ticksize * tickvalue);
   if(lots > MaxLot) lots = MaxLot;
   if(lots < MinLot) lots = MinLot;
   return(lots);
  }

Position Sizing to Equity: this method executes the trading order according to the trading account’s equity. For example, the developer could place one lot per $100,000 in the trading account. This method will increase or reduce each transaction’s volume as the capital of the trading account evolves.

extern double MM_PositionSizing = 100000;
double MM_Size() //position sizing
  {
   double MaxLot = MarketInfo(Symbol(), MODE_MAXLOT);
   double MinLot = MarketInfo(Symbol(), MODE_MINLOT);
   double lots = AccountBalance() / MM_PositionSizing;
   if(lots > MaxLot) lots = MaxLot;
   if(lots < MinLot) lots = MinLot;
   return(lots);
  }

There are other methods, such as martingale and anti-martingale, discussed in a forthcoming educational article. For now, we present your definition.

  • Martingale: this rule is based on the money management of gambling. This method doubles the position size after each losing trade and starts at one position after each win. This method is extremely dangerous and should be avoided.
  • Anti-Martingale: this method opposes martingale, that is, doubles the position size after each winning trade and starts with a position after a losing trade. This method plays with what the trader considers to be “market’s money.” It is advisable to reset the size after a determined number of steps since the logic bets on a winning streak, which will end at some point. A 3-step is good enough to increase profits substantially. 4-step may be an absolute maximum on most trading strategies.

Conclusions

Position sizing is one of the critical decisions that the trading strategy developer must make. This choice will influence both the trading account’s growth and the capital risk to be exposed in each trade.

On the other hand, we have seen three examples of position sizing, representing a criteria guide that the trading strategy developer can use.

Finally, the developer of the trading strategy should explore and evaluate which is the best option of position sizing to use, taking into account the benefits of each of the impacts on the strategy’s execution.

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).