Log in to see Cloud of Tags

Wealth-Lab Wiki

Testing Trading System Filters with Analysis Series View

RSS
Original tutorial idea: Dion Kurczek.
Re-created for WL6 by Eugene.


Wealth-Lab 6 provides a way for you to test the effects of different indicator filters on your trading system results - the Analysis Series view found in the Extra Performance Visualizers library. This performance visualizer lets you analyze how a particular indicator or data series correlates to trade profitability. You can also quickly see how filtering on the indicator would have impacted the performance of the trading system.

This can be a simple indicator series such as SMA.Series or RSI.Series, or can be a custom data series that you have created yourself either on-the-fly or in a custom Indicator Library. It just takes creating a data series in your strategy (or adding a condition to rule-based strategy).

The Strategy window contain an output tab dedicated to Analysis Series results. At the top of the tab is a drop down list where you can select one of the Analysis Series that you defined in your ChartScript. Below this are two graphs that visually depict the relationship between the Analysis Series values and the percentage profit per trade.

The first graph is simply a scatter-plot of the Analysis Series value by individual trade net profit percentage. Each point on the graph represents a single trade generated by the system. If the data points form a discernable line or slope, rather than an evenly-distributed cluster, you'll know that you've discovered a relationship worth pursuing further. You can check the exact statistical correlation below the graph heading.

The second graph allows gives you an idea of how filtering on an Analysis Series would have affected the overall system results. It displays average trade percentage profit using a range of Analysis Series filter values. Each bar of the graph represents the average system profit per trade if you had filtered the system based on a specific level of the Analysis Series. You have the option of displaying the graph so that it filters based on Analysis Series values greater than or less than specific values.



Example - QQQQ Crash System

Here we have a system from James Altucher's book "Trade Like a Hedge Fund". It buys when the market makes a statistically significant move down and then sells on the first profitable day or after 20 days of holding an unprofitable position.


using System;
using System.Text;
using WealthLab;
using WealthLab.Indicators;
using System.Drawing;

namespace WealthLab.Strategies { class QQQQCrash : WealthScript { //Create parameters private StrategyParameter bbPeriod; private StrategyParameter bbStdDev; private StrategyParameter exitDays;

public QQQQCrash() { bbPeriod = CreateParameter("Bollinger Period", 10, 6, 20, 2); bbStdDev = CreateParameter("Std Dev", 1.5, 1, 3, 0.25); exitDays = CreateParameter("Timed Exit", 20, 1, 30, 1); }

protected override void Execute() { //Obtain parameters values int bbPer = bbPeriod.ValueInt; double bbSD = bbStdDev.Value; int timedExit = exitDays.ValueInt; BBandLower bbL = BBandLower.Series( Close, bbPer, bbSD ); PlotSeries(PricePane, bbL, Color.Silver, LineStyle.Solid, 2); for (int bar = bbPer; bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position Pos = LastPosition; if (bar + 1 - Pos.EntryBar >= timedExit) SellAtMarket(bar + 1, Pos, "Time-based"); else if (Close[bar] > Pos.EntryPrice) SellAtMarket(bar + 1, Pos); } else { if (Close[bar] < bbL[bar]) if( BuyAtMarket(bar + 1) != null ) LastPosition.Priority = -Close[bar]; } } CMO cmo = CMO.Series( Close, 7 ); } } }



Backtesting results

I ran a 10 year (January 1999 to December 2008) portfolio simulation of the strategy on the Nasdaq 100 stocks with the following performance results:

Equity curve before applying Analysis Series filter

Equity curve before applying Analysis Series filter


The system had clearly more winners than losers. It netted a 455% return over the historical period - pretty impressive and surpassing the Buy&Hold figure of 317%. The average trade size was an acceptable 0.50% (after subtracting commissions according to a commission plan actual at those years and 0.05% slippage per trade). However, the system was overexposed the the market (4/5 of the time) and it leads us to think that using the system in its current state leaves something to be desired.

I'm interested in seeing if there are any advantages to implementing a filter on the system based on the Chande Momentum Oscillator. CMO (Chande Momentum Oscillator) measures pure momentum and oscillates within the range of -100 (oversold) and 100 (overbought). It is similar to RSI or Stochastics. You can look for signals based on the CMO when it reaches extreme overbought and oversold levels. Particularly, I'm interested in seeing if filtering the system so that it only buys when the market is oversold (low CMO values) would improve the results.



CMO Filter Analysis

It's now time to explore the idea of adding a filter based on Chande Momentum (CMO). Let's turn to the Analysis Series view to explore the results further. The scatter-plot doesn't display any particularly striking relationship.

Take a look at the second graph, however. It's clear that the average net profit per trade is greater when the trades were filtered by CMO. The effect becomes noticeable when a filter for CMO < -60 was applied.

Analysis Series filter

Analysis Series filter


A note explaining why didn't we pick the pretty "-80" bin. When performing optimization of any kind, try to avoid such sharp spikes because they do not represent robust performance and are unlikely to produce similar results in the future. Make sure that you've selected a value that was representative of the stable area of profitable results in the middle of the optimization range.

Adding the CMO Filter

Based on a visual inspection of the graph, let's implement a filter of CMO <= -60 and re-run the backtest. Make your entry block look like the following:


					if (Close[bar] < bbL[bar])
						if( CMO.Series( Close, 7 )[bar] < -60 )							
							if( BuyAtMarket(bar + 1) != null )
								LastPosition.Priority = -Close[bar];


Equity curve after applying Analysis Series filter

Equity curve after applying Analysis Series filter


The results are impressive. The system's net profit tripled, soaring to 1370%, but its exposure drops to 59% from nearly 80%. The number of trades, thanks to filtering, is still high but considerably less than before: reduced to 3287 from the initial 4171 - a good relief by 1/5.

Spread the Wealth!

We're sure you'll figure out many creative uses to the Analysis Series feature. Please be sure to share your findings with the rest of the Wealth-Lab.com community!

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.