Categories
Forex Daily Topic Forex System Design

Trading Algorithms IX – RSI Failures System

Trading the naked RSI system depicted in this series’s previous video as an overbought/oversold signal generator is too risky, and its long-term results questionable. The system is profitable only in sideways movements. Thus, a trending filter or a detrending step will be needed to avoid the numerous fake signals.

Divergences and Failure swings

Welles Wilder remarks on two ways to trade the RSI: Divergences and Top/Bottom failure swings.

Divergences

A divergence forms when the price makes higher highs (or lower lows), and the RSI makes the opposite move: lower highs (or higher lows). RSI divergences from the oversold area show the market action starts to strengthen, an indication of a potential swing up. In contrast, RSI divergences in the overbought area show weakness and a likely retracement from the current upward movement.

Failures

An RSI Top failure occurs with the following sequence of events:

  1. The RSI forms a pivot high in the overbought area.
  2. An RSI pullback occurs, and an RSI pivot low forms.
  3. A new RSI pivot high forms, which is lower than the previous pivot high

Fig 1 – RSI TOP failures in the EURUSD 4H 2H Chart

An RSI Bottom failure occurs with the following sequence of events:

  1. The RSI forms a pivot low below the oversold area.
  2. An RSI pullback occurs, and an RSI pivot high forms.
  3. A new RSI pivot low forms, which is higher than the previous pivot high.

Fig 2 – RSI Bottom failures in the ETHUSD 1H Chart.

According to Welles Wilder, trading the RSI failure swings can be more profitable than trading the RSI overbought-oversold system. Thus, we will test it.

The RSI Failure algorithm

To create the RSI Failure algorithm, we will need to use the Finite State Machine concept, presented in this series’s seventh video.

The Easylanguage code of the RSI system failure is the following:

inputs:  Price( Close ), Length( 14 ), OverSold( 30 ), Overbought( 70 ), 
takeprofit( 3 ), stoploss( 1 ) ;
variables: state(0), state1 (0), state2(0), state5 (0), state6(0), rsiValue(0),
 var0( 0 ), rsi_Pivot_Hi(0), rsiPivotHiFound(False), 
rsiPivotLoFound (False),rsi_Pivot_Lo(0)  ;

rsiValue = RSI(C,Length);

If rsiValue[1] > rsiValue and rsiValue[1] > rsiValue[2] then
      begin
         rsiPivotHiFound = true;
         rsi_Pivot_Hi= rsiValue[1];
     end

else
     rsiPivotHiFound = False;

If rsiValue[1] < rsiValue and rsiValue[1] < rsiValue[2] then
      begin
         rsiPivotLoFound = true;
        rsi_Pivot_Lo = rsiValue[1];
     end

else
     rsiPivotLoFound = False;

If state = 0 then
      begin
        if rsiPivotHiFound = true and rsi_Pivot_Hi> Overbought then
             state = 1    {a bearih setup begins}
     else
           if rsiPivotLoFound = True and rsi_Pivot_Lo < OverSold then
                 state = 5; {a bullish Setup begins}
     end;

{The Bearish setup}    

If state = 1 then
      begin
         state1 = rsi_Pivot_Hi;
         if rsiValue > state1 then state = 0;
         if rsiPivotLoFound = true then
             state = 2;
     end;
    
If state = 2 then
      begin
         state2 = rsi_Pivot_Lo ;
         if rsiValue > state1 then state = 0;
         if rsiPivotHiFound = true then
         if rsi_Pivot_Hi< 70 then state = 3;
     end;

If state = 3 then
     if rsiValue < state2 then state = 4;

If state = 4 then
      begin
        sellShort this bar on close;
        state = 0;
     end;


{The bullish setup}

If state = 5 then
      begin
       state5 = rsi_Pivot_Lo;
       if rsiValue < state5 then state = 0;
       if rsiPivotHiFound = true then
             state = 6;
     end;


If state = 6 then
      begin
         state6 = rsi_Pivot_Hi;
         if rsiValue < state5 then state = 0;
         if rsiPivotLoFound = true then
             if rsi_Pivot_Lo > OverSold then state = 7;

     end;
           

If state = 7 then
     if rsiValue > state6 then state = 8;

 If state = 8 then
      begin
         buy this bar on close;
         state = 0;
     end;
   

If state > 0 and rsiValue < OverSold then state = 0;
If state > 0 and rsiValue > Overbought then state = 0;    

{The Long position management section}

If marketPosition =1 and close < entryprice - stoploss* avgTrueRange(10) then
    sell this bar on close;

If marketPosition =1 and close < entryPrice + takeprofit* avgTrueRange(10) then
    sell this bar on close;


{The Short position management section}


If marketPosition =-1 and close > entryprice + stoploss* avgTrueRange(10) then
     BuyToCover this bar on close;

If marketPosition =-1 and close < entryPrice - takeprofit* avgTrueRange(10) then
     BuyToCover this bar on close;

The results, measured on the EURUSD, are not as brilliant as Mr. Welles Wilder stated.

The trade analysis shows that the RSI Failures system, as is, is a losing system. This fact is quite common. It takes time to uncover good ideas for a profitable trading system. In the meantime, we have developed a practical exercise using the finite state machine concept, handy for the future development of our own trading ideas.

Categories
Forex Daily Topic Forex System Design

Building a Trading System: Elements of a Trading Plan

Now that we know the importance of having a plan, let’s discuss the necessary components of a trading plan.

A trading plan should consist of at least these elements:

  1. A basket of instruments
  2. A trading system consisting of timeframes, permissioning filter, entry rules, trade management: stop-loss, take profits.
  3. A position sizing methodology
  4. A trading record
  5. Trade-forensics analysis.

In this article, we will provide an overview of these elements.

A basket of Instruments

Every asset has its characteristics, and its market movement differs from others on volatility, liquidity, and ranges. Therefore, professional traders track a limited basket of instruments to trade. A few, even, specialize and trade just one instrument.

 

The best criteria to decide which are best are:

  • Liquidity: It means how much trading volume it moves. Illiquid assets are easy to manipulate, spreads (the difference between the bid and ask prices) are wider, and the trading rules fail more often.
  • Price Action: The instrument should have enough swings in the trading timeframe to merit trading it. Instruments that do not move or move too erratically are prone to failed trades. A security that trends are the best.
  • Familiarity: As said, your trading results improve if you’re familiar with how an asset moves, its usual support and resistance levels, the typical length of swings, and so on.
  • Economic Data: Economic news releases affect the security and trading signals fail at the time of the release. Therefore, it is advisable not to trade it in the vicinity of a news release.

The Trading System

As said in our previous video, financial markets are unbounded territories where each trader needs to set his own rules; otherwise, they will be influenced by his emotions and fail. A trading system is their set of rules that enable them a long-term success.

 

Timeframes

The chosen timeframe should match the availability to trade. A trader with a day job would need to select a daily or a 12-hour timeframe, whereas a full-time trader could use shorter frames, such as 15-min, one, two, or four-hour timeframes.

Similarly to asset selection, the trader must familiarize himself with how his assets move in these timeframes and evaluate the liquidity and range at different times and weekdays to choose the best periods to trade.

Permisioning filter

A permisioning filter is a way to avoid trading under determined circumstances. It can be a filter that allows only trading in the direction of the primary trend or an overbought/oversold sign that should be on for a determined candlestick or pattern formation to be valid.

The key idea of the permisioning filter is to screen the trades and pick the ones with the best odds of success.

Entry rules

Entry rules can be technical or fundamental rules to time the market, although we will focus on technical rules.

 

There are two philosophies regarding entries.

  • Enter on the trend’s weakness

This methodology aims to profit from pullbacks of a primary trend to optimize the price entry. Different indicators and patterns may help time the entry: MA crossovers, Oscillators, or reversal candlestick patterns such as the engulfing pattern or morning star and evening star.

  • Enter on the trend’s strength.

Enter on strength aims to profit from an increasing momentum of the price. We acknowledge the trend’s strength is increasing and recognize the trend will continue for a while. Technical indicators such as the Momentum, RSI, and MACD may help time the entry. Price action patterns, such as range breakouts, are quite useful too.

Trade Management

Trade management is a vital element of any trading system. It is responsible for getting out of unprofitable positions, trails the stops to break-even, and above to optimize profits or close the trade when the target is hit or when a technical signal warns of a trend reversal.

Many top traders value more trade management than entries. The money is won on exits, they say.

Money management should be consistent with the concept of cutting losses short and letting profits run. A sound trading system should present an average reward/risk ratio at least over 1.5, and ideally above 2.

Position sizing

Position sizing is the part of your plan that tells you how much risk you should take on a trade. We have had a complete video section on this subject, which we encourage you to study. To summarize it here, position sizing is the tool to help you reach the trading objectives and put drawdown under the levels that fit you. Finally, proper position sizing enables you to minimize the risk of ruin while optimizing your trading account’s growth.

The trading record / Trade-forensics

The path to improvement is an analysis of past results. Nobody is perfect, and, also, markets aren’t immutable but changing. A trading record is necessary to evaluate your system’s performance, detect and correct weaknesses, such as stops or target placements, errors in timing – too late or too early on a trade, and evaluate how permisioning filters work. Finally, the trading record will help traders know their system’s key parameters: the average profit and its standard deviation, percent winners, and average reward/risk.

Key Elements of the trading record:

The main data you should record on the spreadsheet record are:

  • Entry date/time
  • entry price
  • trade size
  • entry level
  • stop-loss level
  •  $risk of the trade
  • planned take-profit level
  • Exit price
  • Exit date/ time

Other desirable parameters that would help optimize stops and take-profit targets are:

maximum adverse price of the trade if there were no stops.

maximum favorable price of the trade if not considering the take-profit

The first one would help you find better places for the stops, and the second one will show you the best place for the take-profit placement.

Main Parameters:

With the suggested trading record entries, you will be able to measure the key parameters of your system:

Average profit: Total profits/ number of trades

Standard deviation of profits: Use Excel’s Standard Deviation formula

Percent winners: Nr of Winners/ total trades x 100.

Average Reward/ risk:  Sum of Profits / sum of $risk

You may find an example of a trading record in this forex.academy article. Furthermore, since we consider it an essential element to your trading success, we offer you to download our freely available trading log. You are free to adapt it to your taste and needs.

Forensics

After the closure of a trade, you should analyze its quality, regarding execution and goals. A losing trade does not have to be of low quality if executed according to your system’s rules. But it is necessary to determine if you’re acting according to the rules and assess how much of the available profit did you take.

Points to consider

  • Percent of the available profit ( if any)
  • percent of the loss you’ve taken ( if any)
  • Timing: has it been right, too early, or too late?
  • Exit timing: right, too early, or too late?
  • Stop-loss: Can stop-loss settings be improved?
  • Take profit: Can they be improved?
  • Average Reward/risk: is it according to your settings?

Also, after  a determined number of trades/weeks, you should assess:

  • Is the system improving or worsening over time?
  • Losing streaks: are normal for the system you’re using or due to bad stop-loss settings?
  • How many trades could be on profit if you’ve loosened your stops?
  • How much profit could you pocket if your take-profit levels were moved here/there, based on the maximum favorable price data?

 

This ends our overview of the main elements of the trading plan.

Categories
Forex Daily Topic Forex System Design

Building a Trading System: Why do you need a trading plan?

The necessity of a trading system has been discussed many times. Still,  new traders don’t consider it important when, in fact, it is a crucial element.  Could you conceive building a bridge without a project, playing tennis, or chess, with no strategy?

 

 

 

 

 

The trading profession is alike. If you take this business seriously, you’ll need to have a plan. Else, you’ll be in the loser team, in which are 90 percent of traders.

Reasons for a trading plan

1.- The financial markets are not deterministic

A market is a strange place where you cannot predict an outcome. An engineer can design a bridge, knowing that he can predict the bridge’s strength and behavior under heavy loads with proper calculations.  In the financial markets, you don’t have the benefit of an analytical formula to success. All you can expect is a small edge. Not following your plan is comparable to random trading; thus, losing the edge.

2.- Not following a plan weakens you psychologically

When you buy a lottery ticket or play roulette, you’re entering a bounded game. You know the cost of your ticket, the reward associated with a successful bet, and you don’t need to make any other decision. All parameters of the play, including the exit time, are fixed.

The financial markets are different. Everything there is unrestricted. The trader decides when, how much, exit time, stops, and target levels.  With so many parameters, a trader needs to define his rules and stick to them. Otherwise, he will be shattered by his emotions and lose money.

3.- The need to measure

Traders need to record and analyze their trades for many reasons.  The first is the need to analyze their performance and see if it has improved or not. Also, if the system performs as expected or lags its past performance. The most important reason is that traders need to know the strategy’s main parameters: percentage of winners, reward/risk ratio, the average profit and its standard deviation.

A trading plan that fits you

New traders don’t know much about statistics, and trading is about odds and their properties. One of them is streaks. There are winning streaks and losing streaks. The point is, streaks are mathematically linked to the ods of the system.

Let’s think of a system as a loaded coin, in which the odds of a winner can be different from 50 percent. Let’s say the odds of a system is 60 percent instead.  That means there is a 60 percent chance the next trade is a winner, and, consequently, a 40 percent chance it is a loser.

But what are the odds of a loser after a previous losing trade (a two-losing streak)? For the second trade to be a loser, the first one should also be a loser.  So the odds of two consecutive losing trades in a row is 0.4 x 0.4 = 16%. The odds of three successive losers would be 0.4×0.4×0.4 =6.4%, and so on.

The general formula for the probability of a losing streak is

n-losing-Streak = prob_lossn

which is the probability of one loss to the power of n, the size of the losing streak.

What we have shown here is that streaks are inherent to trading. In fact, inherent to any event with uncertainty. Golf pros, football players, and spot teams are subject to streaks, which are entirely expected. Trading systems are no different.

So, what’s the problem?

There are a variety of trading systems. Some, such as the well-established Turtles Trading System, which is trend-following, have less than 38 percent winners, although with average reward/risk ratios over 5. Other systems show over 70 percent success but reward/risk ratios of less than 1.

The odds of a 10-losing streak on the Turtles system, assuming 38% winners or 62% losers, is about 0.84%. That means we can expect ten losers in a row every 120 trades.

On a 70% winner system, the odds for ten losers in a row are one every 200 thousand trades.

The rationale behind the turtle is to lose small and profit big. When a Turtle trader sees they are right, they add to their position, and on and on, following the trend.

People who use the later system are scalpers that jump for the small profit and get our fast before the movement fades.

Nobody is wrong. They trade what best fits their psychology. You need to know your limits, as well. Many wannabe traders move from system to system after only a five-losing streak, discarding a sound strategy when its first perfectly normal streak occurs. Also, most traders use sizes inconsistent with the expected streaks and lose their entire account.

By now, you should have learned the importance of having a plan that fits your psychology and trading tastes.

In the coming article, we will discuss the components of a trading strategy or system. Stay tuned!

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).
Categories
Forex Education

Getting Started with your First Historical Simulation

Introduction

In the previous section, we learned the steps to create a trading strategy. At this stage of the trading strategy development, we will focus on the strategy’s simulation process using historical data.

What is the Historical Simulation?

The simulation is defined as a mathematical representation that describes a system or process, making it possible to generate forecasts of such a system.

As the years have advanced, computational technologies have evolved to allow many processes simultaneously performed.  Compared to what a processor could do 40 years ago, a mere smartphone outruns any of them. In this context, the trading strategies simulation has also done so, moving from the simulation using printed paper charts to the current computer systems we observe today.

By running a historical simulation on a trading strategy, the developer should be able to estimate the gains and losses the strategy would have generated under historic market conditions within a given period.

However, while the benefit of executing a historical simulation enables one to estimate the profits and losses and whether the strategy is profitable or not, this statement should be analyzed by the developer throughout the trading strategy developing process.

Getting Started

Once the developer has completed a trading strategy, including entry and exit rules, as well as the definition of risk management and position sizing, it is necessary to formulate the rules of the strategy using a computer language. This way, the trading simulation software will execute the rules algorithm and apply it to the study’s financial dataset.

Several programming languages are able to carry out the trading strategy simulation, such as MQL4 of MetaTrader, Easy Language of Trade Station, or Python. However, for this educational article, we will continue to use the MetaTrader MQL4 language.

First Steps in the Simulator

MetaTrader 4 offers its Strategy Tester to simulate trading strategies. In the following figure, we observe the Strategy Tester terminal, in which we can develop a historical simulation of any trading strategy under study. 

The figure highlights that Strategy Tester has a user-friendly and intuitive interface for the developer, who can select the Expert Advisor that will contain the trading strategy to simulate. Similarly, the user can choose both the financial market, the timeframe, and the date span in which the simulation should run.

Running the First Simulation in Strategy Tester

In this example, we will continue using a moving-average-crossover-based trading strategy. To recap, this strategy is based on the following rules:

  • A buy position will be opened when the 5-hour weighted moving average (LWMA) crosses above the 55-hour simple moving average (SMA). 
  • A sell position will be activated when the 5-hour LWMA crosses below the 55-hour SMA.
  • The buy position will be closed when the LWMA 5-hour has crossed below the SMA 20-hour.
  • The sell position will be closed when the LWMA 5-hour has crossed over the SMA 20-hour.
  • The position sizing will be a constant 0.1-lot.
  • Only one trade at a time is allowed.

The criteria for the execution of the historical simulation are as follows:

  • Market to simulate: GBPUSD pair.
  • Timeframe: 1 hour.
  • Simulation range: from January/02/2014 to October/02/2020.

From the simulation’s execution, we observe the following result provided by the Strategy Tester at the end of the simulation.

From the above figure, we note that the balance line was reduced by $2,230.63 from the initial balance of $10,000, reaching a final balance of $7,769.37. This result leads us to conclude that the average-crossover strategy is not profitable. However, this is just a preliminary result.  It is still possible that we could make this strategy profitable through an optimization process, where we will assess what parameter values perform the best.  We could also add stop-loss and take-profit targets that statistically boost the system into profitable territory.

Conclusions

In this educational article, we have seen the first steps to perform a historical simulation. This process provides the developer with an overview of the strategy’s performance in a given financial market under certain conditions. We highlight that the performance conditions could repeat in the future. For this reason, once evaluated the strategy feasibility in terms of profitability, the developer should test the trading strategy during a specific period with paper money in real-time.

On the other hand, the profitable or non-profitable result is just a snapshot of the strategy’s performance. During the optimization process, the developer will investigate the parameters that provide higher profitability or lower risk for the investor.

The next educational article will review the simulator’s information in detail once the historical simulation has been executed.

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 Indicators Forex System Design

Designing a Trading Strategy – Part 3

Introduction

In our previous article, we presented the first component of a trading strategy, which corresponds to the market entry and exit rules. Likewise, we exposed the case of a basic trading system based on the crossing of two moving averages.

In this educational article, we will present the filters and how they can help the trader refine a trading strategy.

Setting Additional Filters in Trading Strategy

Signals originated in a trading strategy can use filters to improve the entry or exit signals that the system generates. The purpose of incorporating filters is to improve both the accuracy and reliability of the strategy. 

A filter can be an indicator’s level or additional instructions to the initial entry, or exit rules. Some examples of filters can be:

  1. Avoid buy entries if the reading of the 60-period RSI oscillator is less than 49. 
  2. Allow Buy entries if the price closes above the high of the previous day or allow sell-short signals if the price closes below the last day’s low.

Also, rules can be established to control the strategy’s risk, and preserve the trading account’s capital. In this context, two elements that can help to manage the risk are:

  1. Initial stop-loss, which can be a fixed amount of pips or depending on some previous periods’ volatility. In turn, this rule can be fixed or dynamic, its level moving as the trade progresses through time.
  2. limiting the number of simultaneously opened trades. This rule can be useful, mainly when the market moves in a sideways path.

Measuring the Risk of Strategy

The risk of trading strategy corresponds to the amount of capital that the investor risks with the expectation of a possible return on the financial market by applying a set of rules with positive expectations.

One way to measure the risk of trading strategy is through the maximum drawdown, which corresponds to the maximum drop in equity from the peak of the equity value to the subsequent equity low.

The developer can obtain this measure as well as other strategy performance indicators by running a historical simulation.

Incorporating Additional Rules into Trading Strategy

The following example corresponds to the addition of rules to the trading strategy formulated and developed in the previous article, based on  moving averages crossovers with 5 and 55 periods. 

Before incorporating additional rules and evaluating their subsequent impact on the trading strategy, we will display the results of a historical simulation, developed using the EURUSD pair in its hourly timeframe. Likewise, the size of each trade position corresponded to 0.1 lot in a $10,000 account.

The following figure illustrates the strategy’s performance in its initial condition, which executed 652 trades providing a drawdown level of 22.66% and a net profit of -$716.93.

The additional proposed filter rules are as follows:

  • The strategy must have an initial stop loss of 30 pips. This stop will limit the possible maximum amount of loss per trade.
extern double SL_Pips = 30;
  • We propose using a Break-Even rule to ensure the opened trades’ profits, which will be used when the price advances 40 pips. Likewise, the strategy will apply a Trailing Stop of 40 pips of advance and a 3-pips step
extern double BreakEven_Pips = 40;
extern double Trail_Pips = 40;
extern double Trail_Step = 3;

The function that computes the Trailing Stop is as follows:

void TrailingStopTrail(int type, double TS, double step, bool aboveBE, double 
aboveBEval) //set Stop Loss to "TS" if price is going your way with "step"
  {
   int total = OrdersTotal();
   TS = NormalizeDouble(TS, Digits());
   step = NormalizeDouble(step, Digits());
   for(int i = total-1; i >= 0; i--)
     {
      while(IsTradeContextBusy()) Sleep(100);
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if(OrderMagicNumber() != MagicNumber || OrderSymbol() != 
Symbol() || OrderType() != type) continue;
	  RefreshRates();
      if(type == OP_BUY && (!aboveBE || Bid > OrderOpenPrice() + TS + aboveBEval)
 && (NormalizeDouble(OrderStopLoss(), Digits()) <= 0 ||
 Bid > OrderStopLoss() + TS + step))
         myOrderModify(OrderTicket(), Bid - TS, 0);
      else if(type == OP_SELL && (!aboveBE || Ask < OrderOpenPrice()
 - TS - aboveBEval) && (NormalizeDouble(OrderStopLoss(), Digits()) <= 0 ||
 Ask < OrderStopLoss() - TS - step))
         myOrderModify(OrderTicket(), Ask + TS, 0);
     }
  }
  • Also, the strategy must allow a maximum limit of one trade at a time.
extern int MaxOpenTrades = 1;

In this context, the code that will determined the limit reached will be as follows:

   //test maximum trades
   if((type % 2 == 0 && long_trades >= MaxLongTrades)
   || (type % 2 == 1 && short_trades >= MaxShortTrades)
   || (long_trades + short_trades >= MaxOpenTrades)
   || (type > 1 && type % 2 == 0 && long_pending >= MaxLongPendingOrders)
   || (type > 1 && type % 2 == 1 && short_pending >= MaxShortPendingOrders)
   || (type > 1 && long_pending + short_pending >= MaxPendingOrders)
   )
     {
      myAlert("print", "Order"+ordername_+" not sent, maximum reached");
      return(-1);
     }
  • The trading strategy must preserve the account equity using a position size that should be proportional to 1 lot per $100,000 of equity.
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);
  }

Now, the entry rules with the Stop-Loss rule will be as follows:

   //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, MM_Size(), "");
         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, MM_Size(), "");
         if(ticket <= 0) return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
      myOrderModifyRel(ticket, SL, 0);
     }
  }

Finally, the position’s closing code including the trailing stop will be as follows:

  {
   int ticket = -1;
   double price;   
   double SL;
   
   TrailingStopTrail(OP_BUY, Trail_Pips * myPoint, Trail_Step * myPoint, false,
 0); //Trailing Stop = trail
   TrailingStopTrail(OP_SELL, Trail_Pips * myPoint, Trail_Step * myPoint, false,
 0); //Trailing Stop = trail
   
   //Close Long Positions
   if(iMA(NULL, PERIOD_CURRENT, Period1, 0, MODE_LWMA, PRICE_CLOSE, 0) <
 iMA(NULL, PERIOD_CURRENT, Period2, 0, MODE_SMA, PRICE_CLOSE, 0)
 //Moving Average < Moving Average
   )
     {   
      if(IsTradeAllowed())
         myOrderClose(OP_BUY, 100, "");
      else //not autotrading => only send alert
         myAlert("order", "");
     }
   
   //Close Short Positions
   if(iMA(NULL, PERIOD_CURRENT, Period1, 0, MODE_LWMA, PRICE_CLOSE, 0) >
 iMA(NULL, PERIOD_CURRENT, Period2, 0, MODE_SMA, PRICE_CLOSE, 0)
 //Moving Average > Moving Average
   )
     {   
      if(IsTradeAllowed())
         myOrderClose(OP_SELL, 100, "");
      else //not autotrading => only send alert
         myAlert("order", "");
     }

The historical simulation with the inclusion of the additional rules to the trading strategy  is illustrated in the next figure and reveals a reduction in the Drawdown from 22.66% to 10.49%. Likewise, we distinguish a variation in the Total Net Profit from -$716.93 to -$413.76.

Although the trading strategy continues having a negative expectation, This exercise shows the importance of including additional rules to improve the trading strategy’s performance.

Conclusions

This educational article presented how the inclussion of filters into a trading strategy can improve the performance of two key indicators such as the Drawdown and the Total Net Profit.

On the other hand, we did not consider the parameters optimization during this step. Optimization will be discussed in a future article.

In the next educational article, we will extend the concepts of Profits Management and Position Sizing.

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 System Design

Designing a Trading Strategy – Part 2

Introduction

Our previous article presented the three key elements of a trading strategy, which is the base of a trading system. In this second part of the designing process of a trading strategy, we will present the first component of a trading strategy corresponding to the entry and exit.

Trade Positioning and Trading Strategy

trade is made of at least by a buy order and a sell order. In other words, when, for example, the trader places a long position (buy), he should close it using a sell (cover) order.

On the other hand, a trading strategy with a positive expectation can identify and provide both long and short trading opportunities under a specific condition. Similarly, the strategy must be able to determine when to close the trading position and exit the market.

Generating Trading Opportunities

As we have seen in previous articles, a trading strategy is born from an idea that we believe might generate profits in any financial market. In this regard, the entry signals can vary from the simplest to the most complex requirement.

A buy position will arise when the price meets a condition for a bull market. On the contrary, a short position will activate if the market accomplishes the conditions for a bear leg. Some examples of long entries are:

  1. The 5-period fast moving average crosses over the 55-period slow moving average.
  2. The 65-period RSI oscillator closes above a reading of the 52-level.
  3. The price surpasses and closes above the high of the previous day.
  4. The price breaks and closes above the high of the 55-day range.

The definition of the exit rule of the trade must be considered from the basis that an open position in one direction must be closed with a position of equal size and opposite direction. For example, if the trader has opened a long trade, it will be closed with a selling trade. In this way, the developer should define a set of criteria that allow the execution of the closing of the trade. For example:

1) Closing the trade if the price advances 1.5 times the risk of the transaction.
2) The price reaches 3 times the ATR of 14 periods.
3) The rolling average of 5 periods crosses the average of 21 periods.

An example of Trading Signals using Metatrader 4

Metatrader 4 is one of the most popular trading platforms in the retail trading segment. Despite other trading platforms, such as TradeStation, Multicharts, or VisualChart, we will use Metatrader for our example. This platform includes the MetaEditor application, with which the creation of trading strategies can be developed through the programming of custom indicators.

In the following example, we show the creation of a custom indicator based on the crossing of two moving averages. This trading strategy uses a 5-period Weighted Linear Moving Average (Fast LWMA) and a 55-period Simple Moving Average (Slow SMA). 

Now it is time to define the entry and exit rules of our trading strategy as ideas and code rules for MetaEditor of MetaTrader 4.

The setting of each moving average period is as follows:

extern int Period1 = 5;
extern int Period2 = 55;

The entry criterion will occur as follows:

  • buy position will be activated when the LWMA(5) crosses above the SMA(55).
//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;   
      if(IsTradeAllowed())
        {
         ticket = myOrderSend(OP_BUY, price, TradeSize, "");
         if(ticket <= 0) return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
     }
  • sell position will trigger when the LWMA(5) crosses below the SMA(55).
//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;   
      if(IsTradeAllowed())
        {
         ticket = myOrderSend(OP_SELL, price, TradeSize, "");
         if(ticket <= 0) return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
     }
  }

The exit criterion will occur as follows:

  • buy position will be closed if the LWMA(5) crosses below the SMA(55).
//Close Long Positions
   if(iMA(NULL, PERIOD_CURRENT, Period1, 0, MODE_LWMA, PRICE_CLOSE, 0) <
 iMA(NULL, PERIOD_CURRENT, Period2, 0, MODE_SMA, PRICE_CLOSE, 0) 
//Moving Average < Moving Average
   )
     {   
      if(IsTradeAllowed())
         myOrderClose(OP_BUY, 100, "");
      else //not autotrading => only send alert
         myAlert("order", "");
     }
  • sell position will be closed if the LWMA(5) crosses above the SMA(55).
//Close Short Positions
   if(iMA(NULL, PERIOD_CURRENT, Period1, 0, MODE_LWMA, PRICE_CLOSE, 0) >
 iMA(NULL, PERIOD_CURRENT, Period2, 0, MODE_SMA, PRICE_CLOSE, 0) 
//Moving Average > Moving Average
   )
     {   
      if(IsTradeAllowed())
         myOrderClose(OP_SELL, 100, "");
      else //not autotrading => only send alert
         myAlert("order", "");
     }

Until now, we have not defined a money management rule or the position size for our trading strategy, just entries, and exits.

Conclusions

Entry and exit criteria are the basis of a trading strategy, which arises from an idea. The trading strategy’s essential objective is to obtain an economic profit from applying specific rules in both long and short positioning in the financial market.

In this educational article, we presented the case of a trading strategy based on two moving averages crossovers. In particular, we used the LWMA(5) as the signal moving average with an SMA(55) as the slow m.a.

In the following article, we will present some filters to avoid false signals.

Suggested Readings

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

Econ Power Trader Review

Econ Power Trader was created by independent trader Leo Castle. You probably haven’t heard his name before, although he has worked for several banks and funds on Wall Street for the last 12 years. 

Overview

Econ Power Trader is a fully automated Expert Advisor that uses adaptive technology to trade the news and reacts to big spikes in the market that are caused by world events. The system uses technology that is advertised to help skip losing trades with minimal risk and low drawdown, while allowing traders to profit from news events with 20%, 50%, or more in profits. Here are a few more facts about the software:

  • Beginner-friendly with easy installation 
  • Uses Adaptive News Trading Technology (AINTT) for higher accuracy
  • Uses a tight stop-loss no higher than 15 to 20 pips on every trade to reduce risk along with double trailing stop protection
  • Trades on most major pairs
  • Does not use risky grid or martingale strategies
  • “Strategically identifies high impact news for any given day, then utilizes pending orders above and below the current price action”

The website spends a lot of time talking about the 70%, 1700%, and 1469% profits that the robot has brought in for the developer without ever requiring them to place a single trade themselves. One of the primary marketing points for the system is a high reward to risk ratio.  

Service Cost

The product’s website doesn’t actually provide the minimum deposit requirement, which leaves us a bit on the fence considering that this could be anything from around $50 into the thousands. The good news is that the website mentions that it is possible to start with a small account with little to no experience, so we expect the asking amount to be on the smaller side. A money-back guarantee is advertised for the first 30 days after purchase. There are two price options for acquiring the product:

  • Pay $297 per year (equating to roughly $24 per month)
  • Purchase a lifetime license for $497

The lifetime purchase is the most economically savvy option in the long run, while the yearly price is cheaper in the short-term. You’ll need to decide which option is the best based on what you’re willing to pay and how long you plan on using the robot. 

Conclusion

Econ Power Trader was designed to be a speedy and efficient system that profits by trading the news using AINTT technology. It was created by professional trader Leo Castle, who has spent a lot of time working for banks on Wall Street. The system was designed to trade the news with a high reward ratio versus risk, meaning that traders should either profit pretty significantly or only lose enough money to put a small scratch on their account per trade, according to the developer.

The system also employs several features to help limit losses, such as avoiding historically dangerous strategies and using a stop loss and double trailing stop protection on every trade. User reviews are not provided on the product’s actual website, but those that are looking for feedback can find several other product reviews online. We were left feeling a little disappointed that these results were posted by other websites and that there weren’t more honest user reviews out there, but the safety, promises, and 30-day money-back guarantee offered by this trading robot seem promising, nonetheless. 

Categories
Forex System Design

Introduction to Walk-Forward Analysis – Part 2

Introduction

In the previous part, we introduced the walk-forward analysis concept, its objectives, and its advantages. This educational article will continue discovering the benefits of using the WFA and how to set it up.

Walk-Forward Analysis and Market Impacts

The walk-forward analysis provides information about the impact of changes in trends, volatility, and market liquidity on the performance of the trading strategy or system. Generally,  when these changes occur, they arrive at a fast pace, heavily degrading the trading performance.

The WFA may extend its study in a wide range of time; however, analyses and evaluates the trading performance by separate windows. The broad range of results obtained by the study could provide the developer with a piece of useful information about the market changes impact the trading strategy performance.

Parameters Selection

As a robust optimization system, the WFA can provide the most appropriate parameters for real-time trading.

Simultaneously, the walk-forward analysis provides the strategy developer with the duration of the optimal period of time in which the set of parameters will consistently produce real-time benefits before the deterioration in trading system performance occurs.

Statistical Rigor in the Walk-Forward Analysis

As mentioned above, a large amount of data provides greater confidence in any phenomenon’s statistical study. This concept is also valid in the walk-forward analysis.

In this context, the walk-forward analysis must be large enough to produce several trades such that a large amount of data can be generated for the study. According to Pardo, in his work, he says that a WFA must be as long as possible, usually at least 10 to 20 years, whenever possible. Finally, he adds that these multiple walk-forwards combined performance will often be sufficient to produce the statistical rigor required in the analysis.

As a result, WFA’s multiple optimization windows will be able to give the developer a better idea of how the trading strategy will behave in the face of market changes.

Developing the Walk-Forward Analysis

A walk-forward analysis consists of two stages. In the first section, traditional backtest optimization is developed. The parameters of the trading strategy are analyzed using a sample established according to the developer’s objectives.

The second stage, which is the one that characterizes a walk-forward analysis, evaluates the performance of the parameters using an additional sample that was not used during the previous optimization stage.

The walk-forward analysis process requires the following elements to be set:

  1. Scan range for variables to optimize. The developer must define the time frame in which the trading strategy’s optimization should be performed. The developer should consider that the scan range uses a computational resources level that it will use to evaluate and weight the parameter to be optimized. In this regard, an exploration in a small number of historical simulations will consume less computational resources than a more extensive optimization.
  2. Identify a target or a search function. The developer must define what the purpose of the optimization study is.  A usual target can be a mix of the normalized average trade return (the reward/risk factor), the standard deviation of this figure, and the percentage of winning trades. These three factors will define the quality of any trading system. A fourth key factor is the number of monthly trades delivered by the system.
  3. Size of the optimization window. Generally, this optimization range can vary from 3 to 6 years. This duration depends on different factors such as, for example, the market, the type of trading strategy, the confidence level required by the developer in the optimization results, among other factors determined by the developer.
  4. Size of the walk-forward out-of-sample window. This period is defined based on the optimization window. In most cases, this window can be between 25% and 35% of the optimization time.

The length of the optimization window is determined by:

  1. Availability of data. Depending on the type of market and accessibility of the data to perform the analysis, the developer might find a restriction on the amount of historical data needed to perform strategy optimization.
  2. Trading strategy style. A short-term trading strategy should require a smaller optimization window than a long-term strategy.
  3. The pace of trading strategy. The pace of strategy is highly variable and tends to vary from strategy to strategy. For example, a long-term strategy, such as swing trading, will slower than a short-term trading strategy, which will require less time to produce the same number of trades.
  4. The relevance of data. The relevant data depends on a large number of factors that could empirically be determined. However, Pardo proposes a basic guideline stating that a short-term strategy can be tested using one or two years of data, whereas an intermediate-term strategy would require two to four years, and a long-term strategy four to eight years of data.
  5. The validity of the strategy’s parameters. The developer expects the parameters employed will generate benefits in the historical simulation. Furthermore, it also requires a trading strategy to produce profits in real-time market trading.

Finally, the walk-forward analysis is a post-optimization method, highly effective and revealing when it comes to discriminating a trading system’s robustness. Regarding that, the market is dynamic and changes periodically; the trading system should be re-optimized with a certain periodicity.

For example, a properly optimized short-term strategy could be re-optimized between three and six months of real-time trading. While the long-term between one and two years.

Conclusions

In this second and final part, we reviewed the basics of walk-forward analysis, characterized by providing the trading system developer with a powerful tool for testing, validation, and measuring trading strategy. Among the benefits that this stage of the development of a trading system provides we can mention:

  1. Measurement of robustness.
  2. Reduction of overfitting.
  3. Assessment of market changes in the trading strategy.
  4. Selection of optimal parameters for the strategy.
  5. Statistical reliability, when correctly applied.

Finally, despite the benefits provided by this analysis methodology, the strategy developer should consider that the trading system may need to be re-optimized with a certain periodicity.

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 System Design

Introduction to Walk-Forward Analysis – Part 1

Introduction

Once completed the optimization process of a trading system, the developer could develop an advanced strategy optimization method, the walk-forward analysis. In this educational article, we will introduce the basic concepts of this methodology.

What is Walk-Forward Analysis?

The Walk-Forward Analysis (WFA) is an advanced method for testing, validating, and optimizing a trading strategy, by measuring its performance using out-of-sample results. The WFA attempts to achieve the three objectives identified as follows.

  1. Determine if the trading strategy continues being profitable using unseen or out-of-sample price history.
  2. Find out the optimal values of the parameters to be used in real-time trading.
  3. Delimit the optimization window size and the period at which the system should be reoptimized.

Measuring the Robustness of a Trading System

A robust trading system is profitable, even when the actual market conditions change. These profits tend to be consistent, with the results obtained in the historical simulation stage. In other words, a walk-forward analysis allows the system’s developer to determine if the trading strategy can produce real-time profits.

The system’s developer is able to compute the robustness of a trading strategy using a statistical criterion called Walk-Forward Efficiency (WFE) ratio, which measures the current optimization process’s quality.

The WFE ratio is computed by the out-of-sample annualized rates of return divided by the in-sample returns. A robust trading strategy should achieve reliable performance, both in-sample and out-of-sample data. A 100% ratio would indicate that the out-of-sample figures match exactly the returns obtained with the backtests. That would indicate the system is sound and reliable.  Pardo, in his book The Evaluation and Optimization of Trading Strategies, comments that “robust trading strategies have WFEs greater than 50 or 60 percent and in the case of extremely robust strategies, even higher.”  A WFE ratio below 50% would indicate poor performance. Finally, ratios over 100% are suspicious, and the system should be analyzed to discover the reason for this behavior.

WFA and Overfitting

Overfitting is a condition resulting from an excessive readjustment of the strategy’s parameters aimed at artificially improve its performance. An overfitted strategy is likely to lose money in real-time trading, even when a historical simulation would present terrific gains.

By its nature, a walk-forward analysis is a cure for overfitting abuse. This edge comes from the fact that the WFA evaluates the strategy’s performance using data not belonging to the optimization process.

By using WFA, the developer is certain about the robustness of a trading strategy. In other words, a not too robust trading strategy would not pass a walk-forward analysis.

Considering that a large number of samples increase the statistical validity and confidence, it is unlikely that an unprofitable trading strategy would make significant profits using a large number of samples. Consequently, a poor trading strategy delivering gains could be the product of chance.

Conclusions

The Walk-Forward Analysis (WFA) is a powerful tool for testing, validating, and measure the quality of a trading strategy, which is characterized by the use of out-of-sample data to evaluate its performance. In this educational article, we have presented the advantages of using WFA to evaluate the strategy’s robustness and how WFA can help the developer avoid overfitting, increasing confidence through an objective statistical measure.

In the next educational post, we will continue reviewing the benefits of using the walk-forward analysis and setting up the walk-forward analysis.

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 System Design

Creating Your First Trading System – Part 1

Introduction

In our previous articles, we presented the introductory concepts to design, create, test, optimize, and evaluate a trading system. In this section, we will be using a practical example of the development process of a trading system.

Starting to Build the Trading System

In his work, Robert Pardo exposes a seven-step methodology that must be followed to develop a trading system. These steps are as follows:

  1. Formulate the trading strategy.
  2. Write the rules in a precise form.
  3. Test the trading strategy.
  4. Optimize the trading strategy.
  5. Trade the strategy.
  6. Monitor the trading performance and compare it to test performance.
  7. Improve and refine the trading strategy.

Picking a Trading Strategy

A trading system starts with an investment idea that could arise from a publication in a specialized trading site or another related source. In our case under study, we are going to develop a trading strategy based on the Turtle Traders. 

Our reader must consider that the process applies to any other strategy.

The Turtle Trading System Rules

The Turtle System uses the following set of rules:

  • Timeframe: Daily range.
  • Entry:
  • Richard Dennis defined two systems; the first one corresponds to a short-term strategy considering the 20-day breakout. In parallel, He added a long-term system using the 55-day breakout. In our system, we will be conservative and use the long-term strategy based on the 55-day breakout.
  • Stop Loss: The stop loss should be placed a the distance corresponding to one time the Average True Range (ATR) of the 20 days.
  • Exit: The system developed by Richard Dennis doesn’t consider a specific take-profit level as it happens with some chartist patterns. Instead, Dennis defines the exit criterion after the price moves against the position for a 10-day and a 20-day breakout. For long positions, the exit will be a 20-day low, and for short positions will correspond to 20-day high. However, to simplify our system, we will consider a profit target level at one  20-day Average True Range distance (1 20-ATR).
  • Position Size: The size will correspond to 1% of the capital available in the trading account.
  • Adding Positions: For educational purposes, we will not consider increasing the positioning criterion.

Charting the Turtle Trading System

As a way to visualize what our first version of the trading system should do, we will illustrate the strategy on a chart for both long and short positions.

In the previous figure, we can observe the set of rules for the entry, stop-loss, and profit-target.  The rule of position sizing will correspond to 1% of capital in the trading account.

Conclusions

In this first part, we identified a trading strategy and specified a set of rules corresponding to what the system should do. In the next educational article, we will start to transform the ideas into a set of instructions.

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.; Design, Testing, and Optimization of Trading Systems; John Wiley & Sons; 1st Edition (1992).
  • Faith, C. M.; Way of the Turtle. New York: McGraw-Hill; 1st Edition (2007).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Conclusions

 

Suggested Readings

  • Jaekle, U., Tomasini, E.; Trading Systems: A New Approach to System Development and Portfolio Optimisation; Harriman House Ltd.; 1st Edition (2009).
Categories
Forex Daily Topic Forex System Design

Introduction to the Evaluation of Trading Systems

Introduction

Once the trading system has been tested and optimized, the developer must achieve its evaluation with a pre-defined set of criteria, which would allow him to decide if the strategy is viable to use or not. To develop this stage, the developer needs to identify which criteria he should use to perform this process.

Why Evaluate a Trading System?

The evaluation of the trading system is the step that the system developer uses to decide if the strategy performance fits the investor’s objectives or if it would be necessary to further optimize the strategy.

Criteria to Evaluate a Trading System

There is a broad range of indicators to evaluate a trading system and compared it with itself or with other strategies. However, the most common indicators are listed below.

Net Profit 

Net Profit is a widely used indicator in the finance world and plays an important place in financial analysis. It measures how much money returns the strategy during the test period. The Net Profit is the result of the sum of all trade results.

Net Profit = SUM ( res(i))

where res(i) are the individual results

The use of this parameter could drive the system developer toward making a biased decision without a risk level consideration, especially when comparing different trading systems. Net Profit is dependent on many factors, such as the frequency of trades and position size; therefore, this figure by itself says nothing about the system except that it is profitable.

Average Trade

The average trade measures the trading system goodness of how much money could return or lose per trade the strategy. Its calculation is the result of Net Profit divided by the number of trades N.

Average Trade = Net Profit/ N

Net Profit should also consider the slippage and commissions spent during the test period.

Percentage of Profitable Trades

This indicator shows the number of winning trades over the total trades. The developer should understand that a trend following system could produce a low percentage of profitable trades and still be a feasible system. However, the developer should weigh how the system is balanced with the average winning trade/average losing trade ratio.

The percentage of profitable trades is computed, as

Percent Profitable = 100 x(Nr of wins/ N) where N is the total number of trades.

Profit Factor

The profit factor is an indicator that measures the gross Profit in relation to gross loss. This ratio is ideal for comparing different systems or the same system compared with different markets. According to Jaekle and Tomasini, a good trading system should have a profit factor higher or better than 1.5.

The profit factor is computed as

Profit Factor = Gross Profit/ Gross loss

where Gross Profit is the total Profit of the profitable trades, and Gross Loss is the total loss of the losing trades.

Drawdown

This popular indicator measures the largest loss or capital decline of a trading system. In other words, the drawdown is the reduction of the equity level. Jaekle and Tomasini, in their work, exposes three types of drawdown identifies as follows:

  1. End trade drawdown measures how much of the open Profit the trader give back before the exit from a specific trade.
  2. Close trade drawdown corresponds to the difference between the entry and exit price without considering what is going on within the trade.
  3. Start trade drawdown tells how much the trade went against the position side after the entry and before it started to go in the direction of the trade.

For simplicity, Jaekle and Tomasini propose closing trade drawdown because they consider it the “most significant.” At the same time, the developer should be careful to use this measure because it is dependent on the trade size

The average drawdown accepted by professional traders and money managers vary from 20% to 30%. Although 10% is considered an ideal drawdown, looking for too small drawdowns may limit the growth of a trading system.

Time Averages

Time averages measure the average time spent in all completed trades during a specific test period of the strategy. The developer should weight the average time elapsed for each trade and the risk taken on each position.

Proposed Preliminary Step

To perform the evaluation properly, a fundamental step is to normalize the trade record, by transforming it to trade only one unit per trade, and also by computing the results in terms of Profit versus risk. Once this is done, the results of a trading system can be properly compared to other similarly normalized systems or its previous variations.

Conclusions

In this educational article, we presented a group of indicators that could allow the system developer to decide with objective evidence what could be the best configuration to apply in the trading strategy or if the system is unviable.

At the same time, the evaluation process must weigh the potential profits with the risk involved during its execution and not make decisions based on a unique criterion, such as the Net Profit or the drawdown.

Suggested Readings

  • Jaekle, U., Tomasini, E.; Trading Systems: A New Approach to System Development and Portfolio Optimisation; Harriman House Ltd.; 1st Edition (2009).
Categories
Forex System Design

Introduction to Optimization of a Trading System

Introduction

Once the system developer tested and validated the trading system, the next stage corresponds to the optimization process. The developer will estimate different values for the key model parameters.
This educational article will introduce the basic concepts in the optimization process of a trading system.

The Optimization Process

Before getting started into the optimization process, the developer must weigh and adjust the investor’s interests with the purpose of the optimization and limitations both the strategy and reality. In this regard, the optimization must align with realistic objectives. For example, the drawdown should not exceed 10% of the trading account, or to obtain a yearly net profit of 15% from the invested capital.

The optimization of a trading system is the stage that seeks the best or most effective use, which allows investors to obtain the highest performance of the trading system. In this context, the optimization could be the search of what inputs could maximize the profits or accomplish the investor’s requirements to minimize the drawdown. To achieve this, the developer must evaluate the variables that conform to the rules and formulas that define and models the system’s structure.

The system developer must consider that an incorrect optimization can drive to obtain serious errors. For this reason, the optimization process is a critical stage in trading system development.

What is the Optimization of Trading Systems?

In general terms, the optimization process is a mathematical method oriented to improve or find an “optimal” solution to a specific problem. In the trading system development, the optimization corresponds to the best parameter selection that allows the strategy to obtain the peak performance in the real market.

Getting Started

Once the system developer tested the trading strategy’s capability to catch market movements, the steps to start the optimization are as follows:

  1. Selection of the model parameters that have the most significant impact on the system’s performance; if a model’s variable is not relevant, it could be fixed.
  2. Selection of a significant range of data needed to test the parameter to be optimized. This range must generate a significative sample to study the model. For example, the amount of data required to evaluate a 20-day moving average is lower than the one needed to assess a 200-day moving average.
  3. Selecting the data sample size. It must be representative enough to ensure the statistical validity to make estimations. The size also must be representative of the market as a whole.
  4. Selection of the model evaluation type, this stage will depend on the evaluation type, objective, or test criteria; this selection will change depending on the kind of trading model.
  5. Selection of the test result evaluation type, this stage must evaluate the results of the optimization process with a statistical significance, meaning the results are not due to chanve. For example, a P-value below 5% would be statistically “significant,” and below 1% would be “highly significant.” Additionally, the average and the standard deviation of the results must be evaluated. As a final note, profit spikes should be considered as abnormal and be discarded.

The figure summarizes the five selections that the system developer must take before to start the optimization process.

Conclusions

The optimization process is a critical stage that comes after the testing process. In this stage, the system developer seeks to determine the appropriate value for the most robust trading strategy implementation. 

Nevertheless, before starting with the optimization, the developer must take a set of decisions, such as which the objective of the optimization? Is it realistic?

Once defined the target of the optimization, the developer must select which parameters to optimize, the range of data to be used in the analysis, how much data will require the sample, which will be the evaluation type of the model, and the evaluation criteria of the test results.

Finally, when all these five steps have been completed, the system developer is ready to start to perform the optimization.

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.; Design, Testing, and Optimization of Trading Systems; John Wiley & Sons; 1st Edition (1992).
Categories
Forex System Design

Testing Process of a Trading System

Introduction

Upon completion of the first steps of the process to build the trading system, the developer must validate the model with a defined confidence level. This evaluation should provide specific metrics to assess the model’s capability to generate profits and the risk of using it.
In this educational article, we will discuss the testing process of a trading system, including the evaluation and optimization process.

Testing Process

The testing process is a critical stage in the trading system development; in this phase, the developer must validate the system’s behavior in a simulated market context with real data. This process leads the developer toward deciding how much data will be needed to verify the model. 

The data size should be significant enough to provide results with a confidence level, such as in statistical terms, a 95% confidence. Considering that volatility and market dynamics changed in the last 40 years, the consideration of 40 years of data could not be adequate to evaluate the model. In this regard, 5 to 15 years of market data could be enough for the right estimation of the system’s performance.

In the first step, the system developer should realize a back-test evaluating the system’s construction logic and the performance with historical data. The results must be studied with an objective quantitative method as the statistical inference. This process’s results could drive the system’s developer to discover some optimization model based on the market’s synchronicity. 

After this optimization, the next step in the testing process is in terms of Jaekle and Tomasini, the walk-forward analysis. A walk-forward analysis is a series of multiple and successive out-of-sample test over different chunks of the data series. The data used in the walk-forward tests should be unused portions of the historical data.

Once verified the trading system capability to generate profits with an acceptable risk level, the system could be tested using real-time data and paper money to evaluate its performance in front of new market conditions. In this context, the time to run the system should be flexible and dependent on the developer’s experience.

A Question of Samples

A sample is just a portion of the whole phenomenon under study; in a trading system, the event under analysis corresponds to the results from a trading entry series. In this context, the final result corresponds to the profit/loss level generated on each trade. In other words, a sample with one trading signal could not represent the trading system’s capability to generate profits. Therefore, the trading signals generated by the system should be significatively bigger to evaluate its performance, and in consequence, the sample used should be representative of the whole series.

The result from the sample evaluation will be an average of the potential returns of the trading system. Considering the variability of the results, the trading system developer will have to analyze the degree of variation of the returns with respect to the average return. In statistical words, the developer will have to study the standard deviation of the trading system.

An example of this analysis could be the return average of the trading system is $100 per trade with a standard deviation of $15 per trade, this means that the trading system may show returns between $85 to $115 per trade 68 percent of the time. 

Is it Necessary to Optimize the System?

The optimization process is a way to adjust some variables oriented not only to maximize the profits but also to reduce the risk taken on each trade and improve the trailing stop methodology. It could also have to target the reduction of false trade signals, for example, to avoid the market entries when the price action realizes a false breakout. However, according to Jaekle and Tomasini, there exist the possibility of incurring an over-optimization, which could reduce the system’s performance.

Conclusions

The testing process is a step intended to evaluate the trading system’s ability to generate profits and identify the variability level of its results with a confidence level. In this way, the system developer must analyze the system’s performance, using both historical and real-time market data. At the same time, the period required to study the system’s performance in real-time will depend on the developer’s experience. 

The requirement of optimization will depend on the variable to need to be improved. This process could carry the trading system to reduce its efficiency in its capability to generate trading signals. 

Finally, in our next educational article, we will expand the optimization process and some metrics to evaluate the trading system performance.

Suggested Readings

– Jaekle, U., Tomasini, E.; Trading Systems: A New Approach to System Development and Portfolio Optimisation; Harriman House Ltd.; 1st Edition (2009).

Categories
Forex Education

Starting to Build a Trading System

Introduction

A trading system is a set of rules to enter and exit a financial market without human intervention. It could also generate entry signals even when the discretionary trader could not enter the market. However, what should be the first step to create and design a trading system? In this educational post, we will review how to start to create a trading system.

Getting Started

Similarly to any business project, a trading system starts with an idea. This idea could arise from different sources, such as seminars, forum conversations, or specialized magazines, among other sources. 

Once the idea is defined, the developer should create a conceptual model of the trading system, where the developer should describe the basic criteria the system should include. After this process, the programming task must incorporate the following rules:

  • An entry method, 
  • The exit criteria, and
  • The money management formula.

The exit criteria must contain rules corresponding to “risk management” as the initial stop loss level, the final stop or a trailing stop rule, the exit profit target level, and how much money will risk in each trade. Also, they must contain “money management” rules as the position size on each trade. In other words, the system developer must consider that a viable trading system should provide an adequate risk and money management criterion.

The next question to address is, what timeframe should be traded? In general, retail traders tend to think that intraday trading involves less risk than swing trading. However, as the Dow Theory states, the primary trend tends to prevail over the secondary and minor trends. In this context, an intraday trading system might require more monitoring than a swing trading system.

Once a timeframe to trade is chosen, the next decision is what market to trade? The market to trade should be determined in terms of its liquidity and volatility. The systematic investor should consider which liquidity and volatility fit best the trading system so that orders sent to the market hold the needed volatility to ensure a movement in an adequate time lapse.

The Importance of Data Provider

Once the systematic investor chose the market to trade, the developer must define which market data provider will be used by the system to perform market analysis/testing and trade execution. 

A market data provider without a trustable price data could drive the system investor toward problems in the trading system execution, such as in the orders execution process. For instance, Jaekle and Tomasini, in their work, comment that the most popular commodities data providers are CSI (www.csidata.com) and Pinnacle (www.pinnacledata.com); however, both the trading system investor and system developer must evaluate which data provider is best for the market to be traded.

Conclusions

In this educational article, we presented the firsts steps to build a trading system, which, as any business project, starts with an innovative idea or is the result of the investor’s creativity. Once the conceptual model is developed and the programming tasks completed, the trading developer must evaluate and validate the trading system, through back and forward tests analysis, before using real money. This stage will be presented in the next educational article.

 Finally, the following figure summarizes the process of developing a trading system.

Suggested Readings

  • Jaekle, U., Tomasini, E.; Trading Systems: A New Approach to System Development and Portfolio Optimisation; Harriman House Ltd.; 1st Edition (2009).
Categories
Forex System Design

First Steps to Build a Trading System

Introduction

A trading system can be defined as a specific set of rules that automatically determine what to buy or sell without human intervention. What to buy or sell? Where entry and exit of the market? How many positions will place on the market?
In this educational article, we’ll review the first steps to build a trading system.

Difference Between Trading Systems and Trading Strategy

In general terms, a trading system is a precise set of rules which automatically and without any external kind of human intervention, will place an order into the market, including the entry and exit levels. In consequence, since the trading system does not need any human intervention, the results can be verified objectively. 

trading strategy typically features components such as a money management rule, and a portfolio rule that will define when entry and exit from the market.

The money management rule should not be confused with risk management because risk management considers where to place the stop loss and the profit target level. Conversely, money management answers the “how much” question; it determines the position size on a particular trade entry. 

Now, when the developer of a trading system includes a set of rules for portfolio construction, using non-correlated assets, this process corresponds to the portfolio management section of that system, which should target the maximization of its returns relative to the risk incurred.

The First Steps to Build a Trading System

As we commented, a trading system is a set of rules that defines, under certain market conditions, an entry order to buy or sell, which must include predefined stop loss and take profit levels. In this context, an example of pseudo-code of a trading system could be:

  • If the price(close) is higher than the price(high) of 10 days, then buy 0.1 lots.
  • If the price(close) is lower than the price(low) of 10 days, then sell 0.1 lots.
  • Set a stop-order at 1.5*AverageTrueRange(14)
  • Set a take-profit at 2.0*AverageTrueRange(14)

Our example is a basic idea for a trading system that will buy when the price surpasses the highest level of 10 previous days, and sell when the price pierces below the lowest level of 10 previous days. In both cases, the position size will be 0.1 lots, assuming that the system developer risks 1% of its trading account. Our model of the trading system proposed will place a stop-loss at 1.5 times the Average True Range (ATR) of 14 days, and the take profit will locate at 2.0 times the ATR of 14 days. This example did not consider a portfolio management rule. Until now, we assume the trader will work on a single market.

Considering that a trading system can be validated objectively using statistical methods, a system developer should consider these five steps to building a trading system:

  1. Observation of the financial market activity to discover a relationship between a group of variables.
  2. Hypothesis definition originating from the relationship between variables that causes some effect in the market.
  3. A Forecast arising from the potential effect of the interaction of the variables under study.
  4. Verification of the model employing real market data, using statistical methods.
  5. Conclusion based on the results obtained on the verification process and considering a determined confidence level. 

Conclusions

A trading system is a specific set of rules oriented to take market entries, including stop-loss and take profit levels, without human intervention.

The development process of a trading system requires a systematic methodology before placing it to work into the real market. The steps that the developer should have in consideration are as follows:

  1. Observation.
  2. Hypothesis.
  3. Forecast.
  4. Verification.
  5. Conclusion.

Suggested Readings

Jaekle, U., Tomasini, E.; Trading Systems: A New Approach to System Development and Portfolio Optimisation; Harriman House Ltd.; 1st Edition (2009).

Categories
Forex Educational Library

Designing a Trading System (V) – Testing Exits and Stops

The importance of exits

It’s not possible to create a system based only on almost perfect entries and using random exits and stops. As we could observe in the entry testing example, the percent profitability of an entry signal is very close to 50%; a coin flip would reach that score. The real money is made directing our efforts into proper risk control, money management, and adequate exits.

Test methods for exits and stops

Testing exits independently are much more difficult than testing entries. Sometimes the entry and the exit is mingled together in a way that’s difficult to separate, for example, when trading support-resistance levels. If that’s the case, the best way is to test the entire system at once.

When it’s possible to evaluate exits by themselves Kevin J. Davey proposes two approaches:

  • Test with one or several similar entries
  • Random entry

The ideas by LeBeau and Lucas move near the same path: Their method of testing exits is to create a very generic entry signal to feed the exit method. If each exit method is tested using identical entries, it should be possible to make valid conclusions about their relative value. Not all exits work equally well with different entries, but if the entry is generic enough, we may get some feeling for the relative effectiveness of a set of exits.

Their method of testing exits is a general approach that encompasses both ways enumerated by Kevin J, Davey.  Nothing is more generic than a random entry, and a non-random entry is improved if we make it close to the type of entry we intended for our system.

Test with similar entries

The fundamental idea behind testing exits, is, of course, to see if it has an edge over a random exit or a benchmark exit. A reliable exit should make a wrong or random entry into a profitable system, and for sure, it should not make an entry system worse.

To create a generic entry signal similar to the one we have in mind for a new system, we need to classify that system. Usually, new systems fall into two categories: Trend following and return to the mean, or counter-trend.

For trend-following systems, Kevin uses an N-bar breakout entry, while for counter-trend systems he uses a relative strength index entry. An exit strategy that works well in similar entry types should work equally well with the intended entry.

Random Entry

The Idea of a random entry is to see if the exit shows an edge by itself. The way to do that is to use a random entry as the optimising parameter with more than 100 runs while keeping the exit fixed and observe what percent of the optimisations are profitable. A very successful exit might have a high percentage of successful series. That is, in my opinion, the best criteria to know if an idea for an exit is valid and has an edge.

Fig. 1 shows the EasyLanguage code for a random entry. This code is a modified version of the one that Bill Brower has explained in his book EasyLanguage Learning-by-Example Workbook. This piece of code can easily be transposed to MQL or another language.

  • Fakecount is used to iterate the optimiser to get several random entry results
  • Initbars is the minimum number of bars the system wait till a new entry signal can be triggered.
  • Randvar is the maximum of bars a random generator can deliver, and it’s added to initbars.
  • BuySell is used to test long and short positions separately 1 for longs -1 for shorts

Fig. 2 shows the 3D graph of a trail-stop exit. We observe that around 0.15%, there is the sweet spot in all random iterations (50 in this example).

In this case, at 0.15% trail stop, the number of profitable iterations were more than 30 out of 50, that is, 60% were positive.

Evaluation criteria

Besides profitability, it’s good to assess the quality of an exit signal based on Maximum Favourable Excursion (MFE) and Maximum Adverse Excursion (MAE) standards.

Those two concepts, developed by John Sweeney, define the maximum adverse excursion (MAE) that a sound signal reaches before it proceeds to run in our favour.

Fig. 3 Show a trading system without stops. We observe that there is a drawdown level beyond which there is almost no winner and mostly are losers. That level defines the MAE optimal stop.

The maximum favourable excursion is the profit level that maximises the result on average of a trading system before it starts to fade and lose profits. MFE is the complementary concept to MAE, but it is a bit harder to visualise.

In Fig. 4 we observe that for the trade in the circle the actual run-up was 0.54% while the real close was 0.3%, the difference is a substantive profit left on the table. The goal of the exit is, on average, to make that distance as short as possible. That means the trading points should be, on average, closer to the upper line, as Fig. 4 shows.

Those two concepts applied to exits mean that the exit must avoid levels beyond MAE, and it should not give back too many profits and get close to the maximum possible excursion.

Total testing

Once we have assessed the goodness of an entry system and have a collection of useful exits to compliment it, we need to test them together and see how entries and exits interact.

The main rule at this point is getting profitability in the majority of combinations of entry and exit signals. For example, if we have ten parameter values on entries and ten on the exits, we would like positive results on more than fifty. Also, I love to see smoothness on the 3D surface. Too many peaks and valleys are a sign of randomness, and it’s not good for the future behaviour of the system, as in Fig. 5

 

Then, we choose a point on the hill that’s surrounded by a convex and smooth surface with similar profitability. That way we are trying to prevent a change in the character of the market which would spoil the system too soon.

Fig. 6  and 7 shows the equity curve and drawdown of a mean-reverting system, and its summary report after having passed the different stages up to the final testing and selection.

With that final assessment, we have achieved the limited testing stage. Therefore, this strategy has passed the test and is a candidate to further forward analyses and optimisations.

 

 

Further readings from this series:

Forex Designing a Trading System (I) – Introduction to Systematic Trading

Designing a Trading System (II) – The Toolbox Part 1

Designing a Trading System (III) – The Toolbox Part 2

Designing a Trading System (IV) – Testing Entries


 

References:

Building Winning Algorithmic Trading Systems, Kevin J. Davey

Campaign Trading, John Sweeney

Computer Analysis of the Futures Markets, Charles LeBeau, George Lucas

Images were taken with permission from Multicharts 11, trading platform.

 ©Forex.Academy
Categories
Forex Educational Library

Designing a Trading System (IV) – Testing Entries

Introduction

Once we develop an idea into a system, it seems straightforward to test it fully assembled, with entries, filters stops and exits. The problem with this approach is that one part of the system may interfere with the behaviour of another part, and its combination may result in such bad results that we could conclude that the original idea has no value at all.

On the positive side, by testing every element of the system independently we’d be able to assess its own characteristics much better, strengths, and weaknesses, and we’d be qualified to better correct and improve it.

For these reasons, it’s much better to create methods to test portions of a trading system in isolation. That cannot be perfect though because a system is an interconnection of its parts, but this way leads to a much better end result.

Entry testing

One of the most revealing situations a believer in Technical Analysis may experience is how their assumptions, when back-tested using a proper method, are shattered by a reality check. Well-known studies that many people are using for trading produce mediocre results when faced with a rigorous test on a mechanical entry system.

According to many authors, all you can ask for of an entry is to give you a bit better than random potential. Once you get that, it’s the exit strategy that is the one in charge to capture as much profit as possible.

One key statistics of an entry signal is the percentage of winners. Everything else being equal, it is preferable to have a high winning system to a lower one. But we must remember that the profit equation includes the reward to risk ratio as well, and this aspect allows having good profitable systems with percentage winners below 50% if the reward to risk ratio is higher than one.

Day traders face a more difficult task. They must develop trading systems with percentage winners greater than 50%, or devise forms to make their profit to loss ratio greater than one, it is also complicated to attain this in short time frames.

On long-term and short-term trading systems, if we wanted to get high percentage winners we’d need a highly precise entry signal; and while exits can be designed to take an optimum part of the generated profits on a trade, its task is much easier if the entry signal is a good predictor of the future price movement.

Methodology of entry testing

There are three methods to assess the quality of an entry signal.

  • Fixed bar exit
  • Fixed target and stop
  • Random exit

Fixed bar exit

This is the most common approach. It’s also an excellent way to evaluate the time characteristics of an entry signal and observe the length of the price move. The idea is to test this using more than one setup. For example, you might be interested to know if a signal has predictive value at  3, 5, 10, 15, 20, and 30 bars. If it has predictive value at 15 to 30 bars, but this is missing at 3 and 5 bars, maybe your signal triggers too early. If it has predictive value in the shorter times but loses it on longer ones, perhaps the signal is too late, or the price movement ends before reaching those bars.

If the entry signal is sound, it should get into the market in the right direction with a winning success significantly higher than 50%. As a rule of thumb, it should show more than 55% winners over a range of markets or currency pairs. That is important, because, after adding stops this figure will decrease substantially, and the better this value is, the tighter the stop can be.

Fixed target and stop

If we set the stop and target at the same pip amount, we’ll get around 50% success if we use a random entry. Assuming the tested signal is better than random it’ll show a better figure. Therefore, we must just set the target and stop levels appropriate for the instrument we’re testing.

Random exit

The concept of a random exit is to eliminate the impact on exits over entries, just seeing the ability of entries to generate profits. If the entry is almost always profitable, even with a random exit, then there is a very good chance that the entry has an edge.

Evaluation criteria

Percentage of winners: A valid way to test the signal. As we’ve said, if we get significantly more than 50%, then our signal may have an entry edge, especially if its winning percent goes beyond 60 percent.

Average profit: We need not only winners but results. Although we are still dealing with just an entry signal, good results are a very good metric to judge its value. That avoids rejecting perfectly valid trading strategies, such as trend following, which typically show less than 40 percent winning rates but with high reward to risk ratios.

One way to assess the robustness of the entry is to perform an optimisation procedure and evaluate the percentage of variations that show good results. If you only get a handful of cases with positive results, the entry method is not reliable. If more than 70% show profits, then you got a successful entry signal.

Study example: MA crossovers using fixed bar exit

Below is a moving average (MA) crossover entry study. We are using a 20-bar exit. We observe that only 9 out of 52 crossover variations are profitable on a 5-year EUR/USD study, and if we observe the MA combinations that are profitable (not shown in the fig) this happens when the fast MA is longer than the slow MA; thus profit comes from fading the original idea.

So, let’s do the opposite study, by shorting when the fast MA crosses over the slow MA instead and buying when crossing under. In fig 2, we observe that the profitability of the inverted MA crossover is much more robust and reliable than the supposedly “good” forward signal. This shows that in intraday trading we cannot take anything for granted and that MA crossovers no longer work in the standard way.

As a final exercise, let’s choose a stop and target for this entry signal and look what comes out. Fig 3 shows a 3D map of the profitability of the combinations. Let’s choose the hill at MAF = 60 and MAS =25, a region that seems to show a robust behaviour.

As we see in Fig 4, this entry system is quite robust along the combinations of trail stop and target. Fig 5 also shows that the trail stop level isn’t critical, but a level at 0.1% will take us out of significant drawdowns and a very good win to loss ratio, at the expense of a fewer profits and 41% percent gainers.

A trailing stop at 0.3% will triple our drawdown with only a minor increase in profitability and a percent profit increase to 45%, that in my opinion isn’t worth the while.

On the target side, we observe that the hill of profitability is reached at about 0.6 % to 0.7%.  Overall this system shows a ratio of profits to max drawdown above 5:1 when using a trailing stop of 0.1%. Below the equity curve using a 0.1% stop and 0.6% target.

Final commentary

By following the steps to evaluate an entry in an orderly manner, we started from a raw idea that showed wrong results and arrived at a possible trading system by tweaking the original idea.

We have just ended the preliminary study. Of course, further tests should be necessary and could possibly improve on our exit management, before committing any money to it.

The idea of this exercise was, of course, to use a trading platform and perform the necessary steps to test an idea, and then either discard it or transform it into a profitable signal, by examining what comes out of a rough process of optimisation, evaluating the resulting data as a whole.

Further readings from this series:

Forex Designing a Trading System (I) – Introduction to Systematic Trading

Designing a Trading System (II) – The Toolbox Part 1

Designing a Trading System (III) – The Toolbox Part 2

Designing a Trading System (V) – Testing Exits and Stops

©Forex.Academy


 

References:

Building Winning Algorithmic Trading Systems, Kevin J. Davey

Computer Analysis of the Futures Markets, Charles LeBeau, George Lucas

Images were taken with permission from Multicharts 11, Trading Platform

 ©Forex.Academy
Categories
Forex Educational Library

Making a Trading Plan using Fibonacci Tools

The Trading Plan

In the previous article, we’ve exposed a brief introduction to the Fibonacci Sequence, retracements, and projection concepts. In this article, we will show how to make a trading plan using Fibonacci Tools, specifically, the retracement and expansion, although we will not explain Risk or Money Management rules and methods.

In practically all industries, with every task, there are procedures to define what to do in each process stage. Professional traders too, have operating methods. In this sense, retail traders have a significant procedural disadvantage compared with professional traders. A way to reduce this gap is to make a working plan. A Trading Plan is a route map, not a treatise, where we will answer the following questions*:

  1. What market to trade? I.e., Forex, Indices, Commodities, EUR-USD, DAX, Gold.
  2. What timeframe should we choose?
  3. What are the market conditions, the arguments for the entry setup?
  4. Where is our stop-loss level; this is the invalidation level of the scenario.
  5. Where to set a profit target or the objective zone of the trade setup.
  6. Finally, a chart including market conditions and its analysis

* Note that this is not an exhaustive list; the reader could incorporate or eliminate decision criteria.

Practical Example

Once we have a good trading plan, let’s consider a specific market and propose a scenario for a trading opportunity. In figure 1, the cross EUR-AUD <EURAUD> in the hourly chart has lost the latest minimum (1.55681) on the 5th December, then it moved on a retracement segment from F(50) to F(76.4). That area could be a potential entry zone for a short-selling setup on a bearish continuation movement.

Fig 1: Potential Reversal Zone. (source: Personal Collection)

In figure 2, we define Profit Target zones; these levels are FE(100) 1.54099, FE(1.618) 1.52333 and FE(200) 1.51424. The invalidation point is 1.57705; this is the maximum reached on the 1st of December.

Fig 2: Potential Profit Taking zone (source: Personal Collection)

 

Some entry possibilities are:

  • Sell Market, i.e. spot price 1.56555.
  • Sell Limit, i. e., F(76.4) = 1.57026.
  • Sell Stop, i.e., F(50) = 1.56267.
  • Sell if price closes below the last low 1.56016.

A summary of the arguments exposed in the Trading Plan example are:

TRADING PLAN
Instrument EURAUD
Timeframe H1
Date Dec-11-2017.
Order Sell
Entry Level 1.56276
Stop Loss 1.57705
Take Profit FE(1.618) = 1.52333
Arguments The price has broken down through a relevant minimum, and currently, it has made a retracement to the F(50) – F(76.4), this is a potential zone for a bearish continuation…
Chart
Trade Result (**)

 

(**) Trade Result: This is not a section for self-flagellation nor a best-trader-in-the-world award as if we were to record +100 pips at the end of a trade. This part is about the “learned lessons” of a finished trade, independently of its result, bringing a higher objectivity to the performance. In summary, the Trade Result is the way to learn about the trades, it is where we have the opportunity to visualise and avoid future mistakes in the execution or to improve the analysis criteria on market entries and exits.

 

SUGGESTED READINGS:

 ©Forex.Academy