SAT2021-18 Aggregate Fisher Index 1

If building and testing last week’s idea was fun, this week was bound to be the opposite.  This week’s idea, inspired by the Sofien Kabaar article on Medium, The Fisher Aggregate Index. Detecting Market Tops & Bottoms With Accuracy, gave me high hopes.  I like Sofien’s frank analysis on the various ideas he generates for forex systems.  He took John Ehlers’ Fisher Transform and tweaked it a little.  He then calculated the Fisher Transform for each of 27 periods (3-period Fisher Transform through 29-period Fisher Transform) and averaged those 27 Fisher Transforms.  He calls the final value the Aggregate Fisher Index (AFI from here on) and uses it to generate trading signals.

The idea is novel.  He is looking for the AFI to hit extremes, like an RSI or other oscillator.  When in extremes, take a trade in the opposite direction. 

I decided to try his idea for futures.  It went downhill from there.  I will warn you now, I was only able to properly test this on one instrument, and just barely.  Here is what I dealt with this week:

  • Short week due to the U.S. Memorial Day holiday
  • I burned out the CPU on my main workstation… for real.  It had been getting flaky for a while, but I finally killed it.  Too many optimizations I suppose.
  • Heavy workload outside of trading.
  • My workstation, currently awaiting a fresh CPU, where I do most of my development and testing, was offline.
  • My laptop is powerful enough, but I was missing some of my trading software, so I could not optimize as I like.
  • Then there were the bugs, and I don’t mean the Brood X cicadas.

Here at Systematic Algo Trader, you get to see the development process warts and all.  This is the way (of an algo trader). 

Phase 1: Plan & Design

1. Trading Idea

I described the Aggregate Fisher Index (AFI) in the Introduction.  The main idea behind the Fisher Transform is to try to get transform the price data into a nearly Gaussian distribution (think bell curve).  Prices are not random nor are they distributed neatly around a mean.  They are chaotic.  John Ehlers created the Fisher Transform to try to normalize price data.

Sofien Kaabar takes this a step further. 

  1. Calculate the Fisher Transform for 3-periods and store the value (CummulativeFisher)
  2. Calculate the Fisher Transform for 4-periods and add to CummulativeFisher
  3. Repeat for each period through 29-periods
  4. Divide the CummulativeFisher by 27 and that is the AFI

When the AFI is in the upper extreme (think ‘overbought’), go short.  When the AFI is in the lower extreme, go long.  It is contrarian trading at it’s core.  Insert some risk management and exits, and you are ready to trade.

2. System Definition

Position Sizing:

I will use the following position sizing:

  • Futures: 1 contract

Input Parameters:

InputData TypeDefaultDescription
UpperBoundDouble2.24Suggested by Kaabar, based on the Golden Ratio plus it’s reciprocal
LowerBoundDouble-2.24 Opposite of the UpperBound
PriceDoubleMedian price, i.e. High+Low/2
LongATRDouble3Multiplier for ATR (Average True Range) in our trailing long stop
ShortATRDouble3Multiplier for ATR in our trailing short stop

Variables:

VariableData TypeDefaultCalculation
MyATRDouble020 period ATR for stop loss and trailing stop calculation
MaxHDouble0Maximum High over n-periods, used in FT calculation
MinLDouble0Minimum Low over n-periods, used in FT calculation
AggFisherIndexDouble0Holds the averaged sum of all the FT calculations
StopPriceDouble0Variable to hold the stop price
PosHighDouble0Position High, for trailing stop on long positions
PosLowDouble0Position Low, for trailing stop on short positions

Entry:

  • Long:
    • If flat or short and
    • AggFisherIndex < LowerBound and  
    • AggFisherIndex[1 bar ago] > LowerBound and
    • AggFisherIndex[2 bars ago] > LowerBound then
    • Buy next bar at market
  • Short:
    • If flat or long and
    • AggFisherIndex > UpperBound and 
    • AggFisherIndex[1 bar ago] < UpperBound and
    • AggFisherIndex[2 bars ago] > UpperBound then
    • Sell short next bar at market
  • Profit targets: none
  • Stop Loss: 1 * MyATR from Entry Price

Exits:

  • Long:
    • Trailing sell stop, PosHigh – (3 * MyATR)
  • Short:
    • Trailing buy to cover stop, PosLow + (3 * MyATR)

Challenges:

  • Puzzling out the AFI calculation 

3. Performance Objectives

The system will meet the following objectives:

ObjectiveGoal
System Type (trend, mean-reversion, day, swing, etc.)Swing
Walk-forward Efficiencyn/a
Risk of Ruin0%
Profit Factor>= 1.5
Win Percent>= 35%
Max Drawdown %< 35%
Profit/Drawdown Ratio>= 2.0
Ready Date2021/06/04

This idea is S.M.A.R.T.: Specific, Measurable, Achievable, Realistic, Time-bound

4. Market Selection

Sectors:

I wanted to test on energies, currency futures, index futures, and metals.  I only ended up with one single instrument.

Markets:

EnergiesCurrenciesFixed IncomeAgricultureMetalsSoftsIndexesEquities
X

Instruments:

Market SectorInstrumentSymbolComments
Currencies-FuturesFutures: Euro FXECAfter numerous issues and delays, this one instrument was the best I could do.

Chart Type, Timeframe, Session, Time Zone:

AttributeValueComments
Chart TypeRegular CandlestickCharting is only useful for validating entry and exit signals
Timeframe / Interval(s)Daily, 60, 240, 360, 480 minute 
SessionRegular 
Time ZoneExchange 

Phase 2: Build

5. Manual Test

To perform a manual test, I had to write a new indicator for the AFI.  That was challenging and educational.  The problem I had is that Kaabar uses a modified version of the Fisher Transform, so that threw me off for a while, since I am used to a different algorithm.  You can see the result in the Manual test section.  The manual test passed for E-mini S&P futures.

6. Build

Process Diagram

Comments:

There is enough complexity to make it interesting, but I do not feel that this system is overly complex in the entry or exit rules.

7. Unit Test

This was a nightmare of a train wreck in a Category 5 hurricane.  Debugging this was a terrible experience.  I had issues with:

  • Funky AFI calculations (my fault)
  • Plenty of zero divisor errors (when you calculate FT 27 times per bar, you are bound to get a few)
  • ATR trailing stops not being hit

In the end, I have a pretty little chart to confirm that my unit test passed.  Barely.

In the end, I was not able to get ATR stops working.  When I have separate code for my exits, it works, which is what you see above.  The problem with this is that it makes optimization exceptionally difficult.

Complete?

Note: Unit Test verifies that the system is executing the trading rules correctly.  It is, essentially, quality control.

Phase 3: Test

8. Optimization

I had to scrap optimization because I had to have my exits outside of my code, where my optimization engine would not see them.  I just went with my default values.    

9. Walk-Forward Analysis

This was a failure.  I will not bore you with statistics and will allow this equity curve (10 years, daily chart), illustrate it. There is one comment I will make about using a long look-back period: If the look-back period started at trade 80 and my walk-forward analysis stopped at trade 200, this system would look stellar. In fact, the longer period (10 full years), gives me a much better picture.

10. Monte Carlo Simulation

We did not make it this far. 

11. Incubation

We did not make it this far. 

Phase 4: Deploy

We did not make it this far.

Trading System Result: FAIL

Notes and Commentary

I love this idea, I really do.  A series of unfortunate events led me to disaster.  The reason I show this is to show you that building trading systems is sometime very, very messy.  Real life happens, computers crash, tropical storms knock out your power, and a host of other hazards.

From the Continuous Improvement department, here is what I will do for the next version of this system:

  • Fix the ATR exits
  • Optimize the upper and lower bounds
  • Optimize the ATR long and short multipliers

I have the core code, albeit with a buggy exit, but I will bring it back, better than ever.  Coding the AFI was the most difficult part, but now I have a new tool for my toolbox.

Thank you for reading and I hope you enjoyed.  Feel free to leave a comment below and let me know what you think.

Next week’s idea:  It is a surprise.  See you next Friday!

Sources/References

Did you like what you read? Do you want to see more?  Subscribe now and receive our weekly email, with the Trading System Idea of the Week and other fun stuff.

Don’t worry, we will never, ever, ever sell, overuse, or donate your email address. Promise.

Did you like what you read? Do you want to see more?  Subscribe now and receive our weekly email, with the Trading System Idea of the Week and other fun stuff.

Don’t worry, we will never, ever, ever sell, overuse, or donate your email address. Promise.

Leave a Reply

Your email address will not be published. Required fields are marked *