You are on page 1of 26

Part I: Building a Trading Strategy in Zignals

For this article I am working with the Zignals MarketPortal which gives full access to all of our services (trading system, stock alerts, stock charts, stock screener, watchlist and portfolio manager) in a single application. The key advantage to the MarketPortal over stand-alone applications is the seamless switching between applications and is recommended for users wishing to publish their own trading strategies. The first strategy will be built around a price cross above a 20-day Simple Moving Average (SMA). This will be a long only strategy. On loading the Trading System interface you will be greeted with a grid-interface; along the top is a set of menu options and on the left is a series of steps, numbered 1 to 5, which are required to create a strategy.

To start creating a strategy first select “My Strategies”. Selecting “My Strategies” will open a window with options to set the risk management and exit rules employed by the trading strategy. The current (first) version of our trading strategy builder offers exits based on percentile targets or optional trailing percentile values; with trailing target and stops profitable trades are allowed run, while underperforming trades are cut short. There is a great deal of flexibility available to adjust these variables and “Risk Management – Zignals Style” in Part II will expand on this. There is no onesolution-fits-all and tinkering these values will be necessary to get the best out of your strategy; strategies built around volatile trading instruments, like leveraged ETFs, will likely benefit from a more open risk management strategy than a risk management strategy built for blue-chip pharmaceutical companies.

Default trading strategies start with $100,000 capital and an allocation of $10,000 per position. Checking „Autocalculate‟ will automatically set the capital invested per trade based on the number of stocks in the strategy (to ensure a strategy doesn‟t overinvest in a situation where simultaneous triggers are given for all constituents). Because I find the „Autocalculate‟ a little too sensitive (i.e. I have yet to come across a situation where all stocks had overlapping entries) I favour a manual set for capital allocation per trade. The strategy is built using 17 stocks (how to select these stocks is step 2) giving an allocation of $5,888 per trade; I have rounded this to $6,000 per position. The commission is set at $10 – standard for most discount brokers. I have left the slippage percentage unchanged. The „Delay Between Trades‟ is used to control whipsaw and represents the minimum number of days between signals; an entry trigger inside the set number of days from the last exit will be ignored. For this strategy I have arbitrarily set this to 5 days. The „Stop Condition‟ defines how trades are exited. The first option is whether to use

a trailing stop. If a trail is not used a position will be exited at either the target or stop percentage from price at entry. E.g. A stock entered at $100 with a 15% target and 8% stop will exit at $115 or $92. To maximise the benefit of following a trend we will use a trailing exit (check the „Use Trail‟ box). In this case the trail kicks in once the initial Target Percentage is reached, but a position will exit if prices reach the Stop Percentage before the trail starts. Once the Target Percentage is hit the rolling target and stop defined by the Trail Percentages is activated. Positions are exited at the Profit Target or the Trailing Stop – whichever is hit first. E.g. In the case of 15% Target, 8% Stop, 10% Trail Target and Stop with a 25% Profit Target, a stock entered at $100 will kick in the trail at $115 or exit at $92. If the stock gets to $115 a new trailing target will be $126.50 with a trailing a stop at $103.50. If the stock gets to $125 then the position is sold (so the position is exited before the next trailing target is reached). The second step is to assign the stocks to your trading strategy. I have created a new stock list, called Active Trader, with the following US stocks: Apple (AAPL), Boeing (BA), Citigroup (C), Caterpillar (CAT), Cisco (CSCO), Disney (DIS), Ford (F), Hewlett Packard (HPQ), International Business Machine (IBM), Intel (INTC), International Paper (IP), J.P. Morgan (JPM), Coca Cola (KO), Microsoft (MSFT), Starbucks (SBUX), AT&T (T), and Wal-mart (WMT). Strategies can also be built using Canadian, Indian, Australian, Irish, UK, Frankfurt or Euronext stocks, Forex or Commodities (Energy and Precious Metals) – the main caveat is assets must share the same currency. The next step is to assign the rules your strategy will use. There are a number of preset rules you can use or you can create your own rules. To add a rule to your workspace first select the rule you want then [+ Add to Strategy]. This introduces the rule to the tile manager right of the grid. Zignals rules can be hidden by un-checking the „Show Zignals Rules‟. To get the most out of the trading strategy builder rules should be created. As a first rule

a simple price crossing a moving average will be used. Select [Technical] – this will open the technical rule builder. To create a rule, first give it a name. Rules are split into two inputs and an operator. A detailed view of available rules is given in Appendix I. The type of rule selected as the „Left Indicator‟ will dictate available options as the „Right Indicator‟. In the example been used, price can be compared against a constant or a Trend indicator; we have created a rule where closing price crosses above a 20-day simple moving average (SMA). Once a rule is created it should be saved. The rule will now be available for selection under „All‟ or under the category of rule it belongs to (in this case „Price‟).

After a rule is created it needs to be introduced into the work space. Select the rule and [+ Add to Strategy]. This places the rule into a rule list on the right; from there it's a matter of dragging it into the workspace.

The first rule dragged-in will automatically connect to the starting point. Other rules you drag-in can either be connected to existing rules, or by dragging the top box down to the new rule, connect to the dragged-in rule (see below).

Multiple rule paths are possible (see below); the key thing is to ensure rules are connected from top to bottom. With multiple rule paths only one signal is supported i.e. trades in a given stock are only entered once – there is no doubling, trebling etc. of positions.

The final step is to connect the price-cross-SMA rule to the end-point to complete the rule flow. Once you are happy with your strategy it should then be saved. Step 4 defines the back-test period. The default period is the past 2years from the previous day, but the back-test period can be run for any period back to 2001 (for US stocks). When a back test is run an historical portfolio is created displaying all the trades over the test period. The portfolio can be given a name (or the default name will be used – usually „Untitled x‟) and will be listed in the drop-down menu of the Portfolio Manager application. The option to view the portfolio is offered at the end of the back test run.

After viewing a back-test portfolio two options are available: [1] The strategy rules can be further edited, with updated portfolios produced OR [2] The strategy can be Published by email. so that the trading signals can be received

To do either it‟s necessary to switch back from the Portfolio Manager to the Trading System. In the Trading System application open the saved Strategy. Any of the aforementioned steps can be edited, but it‟s the final step which activates the strategy and allows you and your subscribers receive the resulting trade signals by email (i.e. the daily monitoring of your strategy begins). Step 5 is the final step and achieves two goals. First it locks the strategy and starts the monitoring process which produces the trade signals. Trade signals are generated after the market close and are delivered by email. Second, publishing a trading strategy makes it available to potential subscribers in our MarketPlace. During the process of publishing a brief description and a subscription charge is set; the income earned from a strategy is split between the trading strategy publisher and Zignals. The Publish Strategy window also gives a summary of the strategy conditions as a final review. Trading Strategy Publishers are automatically subscribed to their published strategies and receive trade signals as they occur. Published strategies also appear in the Published Trading Strategies window and the associated widget in the MarketPortal. Leading strategies are also displayed in the Top 20 Trading Strategies widget of the MarketPortal. Once a strategy is published you should start to receive signal triggers by email.

Part II: Engineer a Strategy with Charts & Excel
Strategies can be designed and built using Trade Timer or the backtest feature of the Strategy Builder. For an individual indicator, Trade Timer is the way to go, but if you are looking to compare a number of indicators together then Charts can be used to identify favoured signal triggers. [1] Select a stock on a two year chart with the indicators of choice. In this example we will use three moving averages (10-day EMA, 20-day EMA and 50-day EMA) with the Money Flow Index. The stock you choose should be representative of the stock(s) you wish to trade with respect to Beta. [2] Highlight the ideal buypoints. This is to focus the eye on the conditions of the technicals at this time (also price relative to the moving averages).

[3] Summarise the conditions of the indicators at the point of the ideal 'Buy' signals.

[4] Run a preliminary backtest to view strategy performance. The above conditions are still quite general, so signals are unlikely to match, but it will give an indication as to what can be expected. Use default risk management and stock list (18 U.S. stocks) on 2 years of data (matching the chart timeframe). Starting Capital is $100,000 with a maximum 10% of capital assigned to any one position. [5] For the record, the S&P gained 10.1% over this period; so anything above this is beating the market, anything below is underperforming. This strategy generated the following statistics

And the following signals in MSFT

The initial prognosis was good; one of our three ideal entry points were hit and remaining signals were close to swing lows. Note: This step is not about profitable trades, it's about timing for good entry signals. For example, the Feb 2010 signal caught the swing low, but under the default exit conditions it closed for a loss. Use the Strategy Statistics and Performance as a guide. [6] Next it's time to optimise the entry signals. We could do this by adding another technical indicator. This time we add Relative Strengh Index (RSI) at a setting of 5bar periods (over the default 14 period) and again record the values of this indicator at our optimum signals:

Our updated values for our strategy are now:

An improvement over the earlier ruleset. The MSFT triggers are now:

The strategy keeps the good February 2010 signal. The June 2010 signal is close enough to considered true, and while the February 2011 signal is well off the desired June 2011 signal, the strategy did catch the later August 2011 reaction low. At this point we won't tinker too again with the signals - next we will look to adjust the exit [7] The signal exit is governed by the risk management settings in the Setup menu. Step 1: How far can the initial stop be tightened in order to maximise the good (swing low) signals? The idea is to minimise damage caused by poor signals like the one in February 2011 for MSFT, while preventing early stop exits in strong signals. Tests of different Stop Percentage suggested an optimum value of 9%. Step 2: How soon should the Trail Targets & Stops be used? The use of Trails is governed by the Target Percentage. When the Target Percentage price is hit the Trail Targets&Stops are activated. Tests of different Target Percentages between 5% and 15% generated little change in Strategy Net Profit, but there was a sharp drop when the Target Percentage was 4% or below.

Although the best profits were returned when the Target Percentage was 5%, it was too close to the drop zone to recommend its use, so the next best was 9%.

Step 3: With the Trail Targets & Stops kicking in after a 9% gain, next is configuring where to place the Trail Stop and how often the Trail Stop should be adjusted by use of the Trail Target. Because most trades will exit at the Trail Stop it's important to give positions a chance to ride the recovery trend. The Profit Target governs the top side exit, but it can be raised so it's not a factor in the final signal exit (e.g. set at 999%). However, this is not the next step. The interdependent relationship between Trail Stop and Trail Stop means pairing each combination is necessary to maximise Strategy Net Profit. This offered the following table for Net Profit

As a mountain chart, Net Profit looked like this

There are two interesting Profit clusters; one which uses a low Trail Target and a loose Trail Stop; the second which uses a moderate Trail Stop and a higher Trail Target. To differentiate which to go with, comparisons are made adjusting the Profit Target for the five lead combinations of Trail Target/Trail Stop. Step 4: The final step is comparing the strongest combinations of Trail Target and Trail Stop to differing Profit Targets (Note: Net profit is slightly different to previous values due to differing backtest dates) The optimum combination of the Trail Target, Trail Stop and Profit Target is 7%, 5% and 25% (Note: testing 24% and 26% as a Profit Target didn't improve returns).

[8] As part of the strategy a quick test can be done to compare performance during a bear market - in this case, from October 1st 2007 to March 31st 2009. During this time the S&P lost 48%, while the aforementioned strategy lost a more palatable, although not ideal, 33%.

[9] Publish your strategy. This will list the strategy on your home page and can be promoted on Facebook or Twitter. Trading signals will also be delivered for free in real-time to your email address. If you are interested in getting the signals for this strategy you can subscribe to it here.

Part III: Risk Management – Zignals Style

The first build of the Zignals Trading System enters trades by technical signals and exits them based on fixed percentile target/stop or trailing targets/stops from price at entry. However, the success of a given exit strategy will be influenced by the underlying volatility (beta) of the component stocks/ETFs/FX pairs in the trading system. In Part I a simple trading strategy was built using default risk management settings. In Part II the impact of risk management changes on a strategy will be investigated – but with an attempt at not trying to 'best fit' the output. The core stocks in the trade system and associated Beta values are listed in the table on the right. The seventeen stocks had an average Beta of 1.36 which was slightly more volatile than the underlying market. The Beta ranged from a low of 0.2 up to a high of 3.05. Changes were made to „Stop Conditions‟ available under Step 1: My Strategies.

Stock Apple (AAPL) Boeing (BA) Citigroup (C) Caterpillar (CAT) Cisco (CSCO) Disney (DIS) Ford (F) Hewlett Packard (HPQ) International Business Machine (IBM) Intel (INTC) International Paper (IP) J.P. Morgan (JPM) Coca Cola (KO) Microsoft (MSFT) Starbucks (SBUX) AT&T (T) Wal-Mart (WMT) Average Beta

Beta 1.50 1.32 3.05 1.85 1.19 1.15 2.71 1.00 0.73 1.15 2.57 1.20 0.62 0.96 1.30 0.65 0.20 1.36

The following Money Management settings were adopted:      $100,000 Starting Capital $5,872 per trade $10 commission 0.2% Slippage 15-days delay between trades

How do the Stop Conditions work?
The Target Percentage sets the conditions at which the Trail Target/Stop kicks in. The Stop Percentage is the opening risk for the trade, assuming the Trail fails to kick in. Once the Target Percentage is hit the Trail Target and Stop becomes the new exit rules. As each

Trailing Target is hit the Trailing Stop is updated. If at any point the Trailing Stop is hit then the position is exited. The Trailing Target continues until the Profit Target is hit. Once a Profit Target is hit the position is exited. The strategy was based on a long entry following a price cross above a stock‟s 20day SMA. For the back-test period the dates 24th Nov 2007 to 23rd Nov 2009 were used.

What were the returns based on default ‘Stop Condition’ settings?
      Target Percentage: 15% Stop Percentage: 10% Trail Used: Yes Trail Target Percentage: 10% Trail Stop Percentage: 10% Profit Target Percentage: 25% No. of Trades: 142 Profitable Trades: 47% Net Profit: 17%

What happened when ‘Stop Conditions’ were changed?
The adjustment to the initial „Stop Percentage‟ generated the following returns:

The relatively close-to-market Beta of our component stocks allowed for a relatively strong return with a tight stop of 4%, even though there was a sharp drop in the percentage of winning trades. Taking the 6% stop as a fixed point and adjusting the „Target Percentage‟ (the price at which the Trailing prices kicked in) brought an improvement in the percentage of profitable trades. Dropping the Target price from 15% to 10% increased the percentage of profitable trades to a morale boosting 57% with an additional kick on the resulting percentage profit.

Locking the „Stop Percentage‟ at 6% and the „Target Percentage‟ at 10%, then changing both „Trail Target Percentage‟ and „Trail Stop Percentage‟ didn‟t improve the return and in the case of raising the „Trail Target Percentage‟ made the returns substantially worse.

Leaving the „Trail Target Percentage‟ and „Trail Stop Percentage‟ unchanged from default and increasing the Profit Target made modest improvements up to a ceiling imposed by the back test period.

Adopting a „Profit Target Percentage‟ at 50% and going back to „Stop Percentage‟, how would the trading strategy have performed if values of either 5% or 10% versus the favoured 6% were used as the „Stop Percentage‟?

Dropping the „Stop Percentage‟ by a percentage point didn't lose any of the 31% return for the past 2 years. Increasing the „Stop Percentage‟ to 10% gave the strategy a little more breathing room which increased the percentage of profitable trades (on fewer trades) - although there was a slight drop in net profit.

For the purposes of building a new strategy the following settings are a good starting point.       Stop Percentage: 10% Target Percentage: 10% Use Trail: Yes Trail Target Percentage: 10% Trail Stop Percentage: 5% Profit Target Percentage: 25% (or 50%?)

For the simple one-rule strategy used on a core set of relatively price stable US stocks, the largest impact on net profit and percentage of winning trades came from adjustments in the initial „Target Percentage‟ and „Stop Percentage‟ values versus changes in the values of „Trail Target Percentage‟ and „Trail Stop Percentage‟. However, trading strategies built around different assets and rule types will respond differently to the risk management plan outlined here. For example, it‟s unlikely a trading strategy built on x2 or x3 leveraged index ETFs will give as strong returns with a 5% stop percentage as they might with a 10% stop percentage. Only by testing different exit strategies is it possible to get the best out of your developed trading strategies.

Part IV: Modifying and Testing Indicators
For new or existing users of our Trading System builder the time will come to modify or create new technical rules with the objective of finding the most profitable combination of rules for the core group of stocks on which a strategy is based. How can this be achieved? In line with the initial How to Build a Trading Strategy article we will call the new trading strategy "My Second Strategy". We will keep the standard 'Strategy Setup' with the exception of the 'Trail Stop Percentage' which we will set at "10%" instead of "5%". It will be a long only strategy. The Active Trader stock list will be the testbed: Apple (AAPL), Boeing (BA), Citigroup (C), Caterpillar (CAT), Cisco (CSCO), Disney (DIS), Ford Motor Company (F), Hewlett Packard (HPQ), International Business Machine (IBM), Intel (INTC), International Paper (IP), J.P. Morgan (JPM), Coca Cola (KO), Microsoft (MSFT), Starbucks (SBUX), AT&T (T), and Wal-Mart (WMT). Before I jump to the editable rules I will configure the back-test period from the start of 2000 to the end of 2007; effectively covering the last major cyclical bear and bull market. Later I will run an out-of-range test from the start of 2008 to the current day. The key element I will be looking at will be modifying the technical rules. There are two ways of creating your own rules; the first involves modifying an existing rule - if you are doing this you need to do a 'Save As' and give your rule a new name - otherwise your changes won't be saved.

The second way is to create a new rule by choosing either [Technical] or [Candlestick]

For modifying rules I selected for indicators which use a single input parameter/period as testing relative performance is easier. But I did adopt assumptions for a positive trigger. The following technical indicators and their assumptions are given below. [Momentum] RSI crosses above 30 [Trend] Linear Regression slope crosses above 0 [Volume] Money Flow Index crosses above 20 When reporting the initial set of results I only used the outputs given in the Trading System Results - I didn't look to the more detailed outputs offered by the Portfolio Manager.

First Step How did each indicator perform independently?

There were two strong performing indicators: RSI and Money Flow. In the case of RSI the best returns came from using non-traditional period settings, although the total number of trades generated was low (which can skew the results). Similarly, Money Flow also posted good returns using higher period settings. For both RSI and Money Flow, period values of 20 days or more generated an average ROI of over 4% per trade. The caveat is the use of trailing stops and defined targets - not the traditional inverse 'sell' trigger for an exit - so this may in part explain the stronger performance from the longer period range. When you consider the (non-) performance of the S&P over the test period this is quite incredible.

Second Step We could probably stop here and just use either a long period RSI or Money Flow indicator as our entry trigger. But is there a way to improve this return? Will a mixand-match offer a better return? The first match was to use RSI [5] with Linear Regression Slope [5] and Money Flow Index [5]. For each combination type there were a large number of signals, increasing the probability for a good subset of results. For a trigger to be true, all signals must occur on the close of business on the same day.

Pairing of the aforementioned indicators brought improved performance over individual indicators. Better still, using all three in tandem brought the strongest performance with a healthy 156 trades (approximately 22 a year) with an average return of 5% per trade and nearly 60% winning trades. Of the paired indicators, a combination of momentum (RSI) and trend (Linear Regression Slope) brought the best returns at an ROI of just over 4% per trade with 56% winners. A unique feature of the Zignals Trading System Builder is the ability to create multiple trigger paths for a trade. So while the aforementioned examples were created with simple linear paths we can modify them to allow for OR scenarios.

A selection of OR combinations did not improve the ROI of the strategy and was considerably worse than the linear flow of all three rules together. The additional rule path also lowered the ROI of the paired rule set.

Third Step How did paired matches perform using different period settings? Can performance be improved over the individual indicator? The first matched RSI and Linear Regression (Slope).

This combination generated few trades outside of RSI [5] and Linear Regression (Slope) [5] and RSI [10] and Linear Regression (Slope) [5]. The [5] / [5] setting was the best performer with an ROI of 4.15% over the 3.24% ROI of [5] / [10]. Beyond these two the number of triggered trades was too low to generate consistent results; neither combination beat RSI [20] with its 155 trades and ROI of 4.94%. The second match of RSI and Money Flow produced a more diverse range of signals, but there was no significant improvement in ROI; best of the pairings was RSI [10] and Money Flow [10] for a 3.83% ROI, but below the aforementioned 4.94% of RSI [20].

The last comparison paired Linear Regression (Slope) with Money Flow. As with the earlier pairing of Linear Regression (Slope) with RSI, the number of generated trades was low. Linear Regression (Slope) [5] matched with Money Flow [5] or [10] had the most trades with a 3.40% and 2.42% ROI respectively - the worst return for any of the pairings. Fourth Step The final step extends the second step by looking at alternative period settings for the three indicators together. But outside the initial set of RSI [5], Linear Regression Slope [5] and Money Flow [5] there were very few trades.

Out-of-test The final phase ran the two best set-ups from the start of 2008 to the current day. The three-indicator set up - RSI [5], Linear Regression (Slope) [5], Money Flow [5] generated 37 trades with 65% winners and an ROI of 6.92%. RSI [20] didn't perform as strongly with 58 trades on 52% winners and 2.26% ROI.

Global Trading Strategies Based on the aforementioned results I have published the following strategies available in Trading Strategy MarketPlace: Tri-Indicator US, Tri-Indicator UK, Tri-Indicator India, Tri-Indicator Aussie, TriIndicator Frankfurt, Tri-Indicator Forex, Tri-Indicator ETF, Tri-Indicator Irish, TriIndicator Canada, and Tri-Indicator US Dividends. Relative US, Relative UK, Relative India, Relative Aussie, Relative Frankfurt, Relative Forex, Relative ETF, Relative Irish, Relative Canada, and Relative US Dividends How did the strategy perform across market types? This time there was a clear winner:

RSI [20] had an average ROI range of -2.86% to 4.04% with a Standard Deviation of 2.66%. RSI [5] + Money Flow [5] + Linear Regression (Slop) [5] had an average ROI of 4.03% with a range of 0.68% to 7.60% on a Standard Deviation of 2.45% Summary Single even triggers can offer strong returns but sacrifice consistency. Multiple trigger events per trade can improve performance stability across market conditions and market types, even if net return per trade can sometimes be lower.

Appendix I: Rule Types Trend
Exponential Moving Average Accumulation Swing Index Linear Regression (Forecast, Intercept, RSquared, Slope) MACD MACD Signal Moving Average Envelope Parabolic SAR Time Series Moving Average Variable Moving Average VIDYA Weighted Close Weighted Moving Average Welles Wilder Smoothing

Operator
Crosses above Crosses below Smaller Equal or Smaller Equal Greater or Equal Greater Between

Momentum
Bollinger Bands Chande Momentum Oscillator CCI Detrended Price Oscillator High / Low Bands Mass Index Median Momentum Oscillator Price Oscillator Rate of Change Relative Strength Index Standard Deviation Stochatics Swing Index Typical Price Ultimate Oscillator Williams % R

Candlestick
Bearish Doji Star Bearish Engulfing Pattern Bullish Doji Star Bullish Engulfing Line Dark Cloud Cover Evening Star Hanging Man Harami Cross Morning Star Piercing Line Shooting Star Spinning Top

Volume
Chaikin Money Flow Chaikin Volatility Oscillator Ease of Movement Money Flow Index On-balance-volume Positive Volume Index Price Volume Trend Volume Oscillator Volume Rate of Change Williams Accumulation Distribution

Price
Open High Low Close Volume