SPC for Strategy Tracking (2/2)

In my previous post I discussed the application of Statistical Process Control charts in monitoring trading strategy performance. Based on the SPC selection tool  I have decided to use the X and Rm  control charts to track the returns of a trading strategy. The X chart will track the actual returns of a trades and compare these against the mean of historical trades. The Rm chart will track the range between two sequential trades and compare this against variance of the historical trades. This is the proper way of applying control charts in cases where sample size of the live-process is one (a single trade).

Recipe X and Rm chart

The recipe that I have used to construct the X and Rm charts is:

  1. Select a strategy and find the backtest period. This period will be used as “in-sample” period.
  2. Run a backtest over the in-sample period and find the geometric mean i.e. log(return) per trade.
  3. Calculate Xm as the average of the log(return) for all in-sample trades and calculate Rm as the standard deviation of the log(return) for all in-sample trades.
  4. Calculate the upper control limit (UCL) for Xm with the formula UCLXm=Xm+2.659*Rm and the lower control limit (LCL) for Xm with the formula LCLXm=Xm-2.569*Rm.
  5. Calculate the UCL for Rm with the formula UCLRm=Rm*3.267 and the LCL for RM with LCLRm=Rm*0=0.
  6. Plot UCLXm, Xm and LCLXm as fixed lines in the X-chart. Plot the log(return) for each individual trade in out-sample period in the graph.
  7. Plot UCLRm, Rm and LCLRm as fixed lines in the Rm-chart. Plot the delta beteween the log(return) between two sequential out-sample period trades as individual data points.

Note: the formulas of step 4/5 are taken from the Six Sigma Blackbelt memory-jogger  available at www.goalqpc.com

Here is a set of sample charts: 


Tools Setup

The tools setup that I to build these charts is as follows:

  1. Use amibroker strategy report to produce a report of trades over full period (in-sample and out-sample). Add a custom trade-metric to include the geometric mean for the trades.
  2. Import the amibroker report in MS Excel in a seperate sheet.
  3. Maintain a sheet for settings. On this sheet I keep the startdate, the end of in-sample date and the end-date.
  4. In a seperate sheet I keep the table of data that produces the charts. This table has a column for each line on the chart a column for the each data point.
  5. The XM and Rm lines are calculated by using a dynamic named range in Excel. 
    Example for Xm =AVERAGE(nmInSampleReturns) where nmInSampleReturns  is a named range defined by the formula: =OFFSET(ABReport!$S$2;0;0;Settings!$B$15;1) (check excel help for the exact use of the Offset function.
  6. The named range can then also be used as series() data element in the graphs so that graphs are automatically adjusted to changed lengths of in-sample periods.
  7. The steps 1through 6 are automated with VBA code so that when I update a performance report for a strategy the SPC charts are updated as well.

As described earlier, this method is used as visual aid in monitoring strategy performance. I am not convinced it should be used to switch on/off strategies but it is should be helpful as means to trigger the trader when the strategy may be breaking up. The trader should then start to check assumptions that may have changed since strategy inception or to check market conditions (extreme news events) etc. Based on these checks one must to decide to continue or to stop the strategy.

If you would have of any further questions on the SPC charts, drop me a line.

– QD –

5 thoughts on “SPC for Strategy Tracking (2/2)

  1. Interesting approach. I’m not there yet on my trading systems but will be at some point.

    One approach my subconcious is toying with: I think there would be value in keeping a “runs” measurement. A run measure could be maybe 10 trades, or whatever would be statistically significant (students T for small sample?). Then track the out of sample (OS) run against the insample (IS)run on an ongoing basis. Is the expectance better or worse OS than IS? That is the basic question. Of course, one would have multiple IS runs and average their expectancy. And one could have the upper and lower band of the IS runs. And so long as the OS run is in the band, and so long as the collection (statistically significant number of runs) of recent OS runs is showing a similar distribution to the collection of IS runs, then the assessment is that the system is fine. One more thing is that a run would be a rolling 10 periods so that more runs could be analyzed (and so that deviations are more quickly spotted).

    I like this runs approach because it is more than a single trade. And it would be good to see how a run is lining up against historical runs.

    I wish I had the clarity and implementation specifics that you have hear. Kudos on that! I wanted share another set of thoughts that are percolating in this space and get any feedback on that, good and bad.

    • Carl-Two things need to be considered with your approach:
      1) if you are going to group trades into subgroups it is traditional to have a min. of 5 trades in a subgroup. This is not generally based upon statistical significance, but rather a rule of thumb in SPC.

      2) You must ensure that the variation within any given subgroup is not greater than the variation between subgroups. At least 25 subgroups should be generated to evaluate if the process is in control.


Leave a Comment