Trading Idea #014 – 40in20out

A few months ago, I was listening to an episode of Top Traders Unplugged and the participants were discussing trend following systems and made mention of the 40in20out trading system.  I did some digging and found the source, the 40in20out website.

The purpose of the site it to provide a benchmark for CTA’s (Commodity Trading Advisors) to use as comparison to their own portfolios or funds.  A user like you or I can use this as a benchmark to measure our own portfolio performance.  I like to compare my systems to the S&P 500 index, meaning that if I can beat the S&P, I’m doing well. 

The number provided by the 40in20out trading system can be used to calculate Alpha for your system. 

Example:

  • Your system generates 12% return in a year
    • 40in20out generates 10% in a year
    • Alpha = 2% (12% – 10%), in other words your annual return is 2% better than the benchmark

You want a positive Alpha from your system against the benchmark.  The 40in20out strategy is just another trading system applied over a basket of commodities and other instruments, which can then be used as your benchmark for calculating Alpha. 

I want to build this system and see if it works (it is having a torrid year and looks great now).  I have a feeling this works best as a portfolio, rather than individually, but let us see what happens.

Phase 1: Plan & Design

1. Trading Idea

The idea is:

  • Buy when the Close closes above the 40-day High
  • Sell short when the Close closes below the 40-day Low
  • Use an ATR (Average True Range) initial stop
  • Switch to a trailing stop once the initial stop is passed.
  • Re-enter the market in the same direction within 5 days of exit if the Close is above the 5-day high (long) or below the 5-day low (short)

This is an example of a long trade in Silver:

2. System Definition

Position Sizing:

I will use the following position sizing:

  • Futures:  1 contract
  • Variables:
VariableData TypeDefaultCalculation
HH40Double0Highest High of last 40 bars
LL40Double0Lowest Low of last 40 bars
HH20Double0Highest High of last 20 bars
LL20Double0Lowest Low of last 20 bars
HH5Double0Highest High of last 5 bars
LL5Double0Lowest Low of last 5 bars
LastPosInteger0Last position, long or short
StopPriceDouble0Trailing stop price
ATRDouble0Average True Range, calculated over 20 bars/periods

Entry:

  • Long:
    • If Close > HH40
    • Buy next bar at market
  • Short:
    • If Close < LL40
    • Sell short next bar at market
  • Re-entry Long:
    • If number of bars since exit <= 5 and
    • Prior position was Long and
    • Close > HH5
    • Buy next bar at market
  • Re-entry Short:
    • If number of bars since exit <= 5 and
    • Prior position was Short and
    • Close > LL5
    • Sell short next bar at market

Exit:

  • Stop Loss:
    • 1 ATR (initial), ATR calculated on 20 bars
  • Trailing Stop:
    • Long: If LL20 > StopPrice, then set new stop to LL20
    • Short: If HH20 < StopPrice, then set new stop to HH20

No inputs or parameters are required for this system.

Challenges:

None.

3. Performance Objectives

The system will meet the following objectives:

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

I lowered the Profit Factor to 1.3, since I have no idea what I am working with here. 

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

4. Market Selection

Markets:

EnergiesCurrenciesFixed IncomeAgricultureMetalsSoftsIndexesEquities
XXXXXXX

Instruments:

Market GroupInstrumentSymbolComments
CurrencyFutures: Euro FX, Australian Dollars, Canadian Dollars, Japanese Yen, British PoundEC, AD, CD, JY, BP 
AgricultureSoft Red Wheat, Oats, Lean Hogs, Soybeans, CornW, O, LH, S, C 
MetalsSilver, Gold, Copper, Mini-SilverSI, GC, HG, YI 
Fixed IncomeU.S. 30-Year Treasury BondsUS, TY 
Index FuturesE-minis: S&P, Dow, Russell 2000, NasdaqES, YM, RTY, NQ 

I am not doing forex here.  If it works for currency futures, it may work for forex.  Either way, it is about the same to me.

Chart Type, Timeframe, Session, Time Zone:

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

Phase 2: Build

5. Manual Test

I tested on RB and CL, successfully.    

6. Build

The build was a little challenging but creating the process diagram first helped the coding.

Process Diagram

7. Unit Test

The unit test took a long time.  First, there were no entries.  Next, there were no exits.  After that, the trailing stop was not working for the initial ATR-based stop.  After I worked through all the kinks, everything is good.

Complete?

Note: Unit Test verifies that the system is executing the trading rules correctly.  It is, essentially, quality control. It does not tell us if the system is profitable         

Phase 3: Test

8. Optimization

I love this part: no optimization required!

9. Walk-Forward Analysis

I tested over a period starting January 1st, 2000. 

Walk-Forward Analysis (WFA) is where things got weird and quite frankly, paradigm shifting for me. 

Everything failed.  None of the instrument and timeframe combinations passed my tests, even by lowering the Profit Factor to >= 1.3.  I even extended this out to weekly charts, but with no luck.  This is not the weird part.  Here are two equity curves:

The instruments are not important, but the curves demonstrate a point.  I saw a lot of uneven curves like these, which makes nearly all these instruments untradable.  The profit factors alone were not good enough.

~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~ + ~

I had to step aside and think about this for one day. 

  • What is the purpose of the 40in20out?  It is a benchmark to calculate Alpha, as described in the intro of this post.
  • What would happen if I created a portfolio of random futures across the 7 sectors (27 to be precise)?  So, I slapped together a portfolio and boom!
    • Daily Profit Factor: 1.34 (passes)
    • Weekly Profit Factor: 1.58 (passes)

The fact is, it still fails for individual futures, but if I were to trade this in a portfolio, the numbers become staggering.  The futures I chose are a random selection that all have reasonable liquidity.

For purposes of this post and before going further down a rabbit hole, I declare this idea to be a failure for individual futures. 

Because this is interesting, will continue analyzing this portfolio. 

Hypothetical Portfolio 40in20out

  • Testing period: December 23, 2000 to May 4, 2021, just over 20 years
  • Account Size: $225,000
MetricDailyWeekly
Total Return, closed trades$1.09 million$1.04 million
Open Trade P/L$84,728$354,482
Profit Factor1.341.60
Win Rate22.1%27.4%
Number of Trades3,509668
Years Profitable59%77%
Average Trade$287$1,028
Average Annual Return %12.02%9.43%
Average Annual Return on Initial Capital22.1%21.0%
Average Drawdown-$24,761-$31,420
Max Drawdown-$190,363-$274,766
Total Return/Max Drawdown5.743.78

These results include, as always, slippage and commission, one contract per futures instrument, and no reinvestment or pyramiding.  There were two things that interested me.  Firstly, the max drawdown is huge, larger than the account size.  Secondly, if I had added conservative position sizing, either of these could have been over $3 million.  Even so, when comparing my slipshod portfolio to various CTA’s, 20%+ average return is a really, really good return (reference: Nilsson Hedge CTA Ratings).   

Which do I like better?  Weekly.  The PF is higher, the number of trades is lower, thus lowering trading costs,

There you have it.  It failed and it passed.  Since my concern is with individual instruments, I have nothing else to do but write my notes and commentary.  For fun, I will do Monte Carlo on the portfolios

10. Monte Carlo Simulation

As noted in the last section, nothing passed, so there is nothing to do.  However, since the portfolio results were interesting, I ran Monte Carlo Simulation on the weekly and daily portfolios.

The Return to Drawdown ratio is low, but the metric I use is Total Return to Max Drawdown.  The Prob>0, which is the probability that the system will be profitable in 1 year, somewhat aligns with the number of profitable years during seen during the WFA.

11. Incubation

No individual instrument passed.  I do not plan to incubate the weekly or daily portfolios.

Phase 4: Deploy

I will not be deploying the weekly or daily portfolios within our SAT hypothetical portfolio, as I created those as    an academic exercise which is outside of the scope of the original idea.

Overall Result: Fail (?)

Notes and Commentary

Wow.  This was quite the interesting journey.  I thought this system was going to be difficult to build and test, but it was easy.  The results were underwhelming on the individual level.  However, at the portfolio level, the results were outstanding, in my humble opinion.

The 40in20out concept is meant to be used to calculate Alpha, as I mentioned in the introduction.  I suppose if your 40in20out portfolio performs better than your system, over a long period of time, then you should probably just trade the 40in20out portfolio.  As I write this, the 40in20out portfolio (on their website) is current up about 31% for the year (all hypothetical results, of course). 

This idea is very cool, much cooler than I first thought.  You could use the information on the 40in20out site to calculate Alpha for your own system, or you could build your own portfolio with these same rules, as I did, and use that in your Alpha calculation.  Or you could forget that and just build a portfolio with these rules.  In other words, create your own personal CTA.  The difficult thing for a lot of folks, myself included, is looking at the big picture and playing the long game.  This is not something that you would want to trade to make a living, since you may have one or two consecutive years of losses.  Such is the way with trend-following systems.

Can this system be improved?  Here are a few ideas:

  • Gently optimize the entry period (fixed at 40)
  • Gently optimize the exit period (fixed at 20)
  • Try an ATR based trailing stop
  • Add position sizing based on margin requirements
  • Add position sizing based on account size

As a reward for sticking with me until the bitter end, here is the equity curve for the weekly portfolio:

I sincerely thank you for taking the time to read this article.  If you want to stay informed about each new trading idea I test, subscribe to my semimonthly newsletter (below).  If you have an idea you would like to build and test, feel free to leave a comment or reach me on the Comments page and we can discuss. Next time’s idea: TASC Magazine’s Optimized MACD system, the third in the TASC series.  See you then!

Sources/References

Did you like what you read? Do you want to see more?  Subscribe now and receive our email twice per month, with a new Trading System Idea 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 email twice per month, with a new Trading System Idea and other fun stuff.

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

2 thoughts on “Trading Idea #014 – 40in20out

  1. That is really well done and extremely thoughtful analysis, bravo.

    You are so very close, but missing a couple of key ingredients here. Most obvious is the static use of just 1 contract per instrument. Before engaging on any optimization, I would first work on position sizing so that you are normalizing all bets across the portfolio. Exclude FX at your own risk as there have been some amazing moves in there over the years! I would also focus on daily data. Let us know if you find something that works and defeats transaction costs on a 5-min timeframe… How are you stitching together futures contracts on the weekly timeframe? Clean data is paramount.

    There is no miracle in the 40in20out parameter set, but as your research supports it is a good place to begin your investigation of trend and provides a reasonable beta for performance comparison.

    1. Thanks for the response. This was a fun system. To your points:

      • I purposely used only 1 contract, mainly because featuring one idea per week on this site applies time constraints. I think I will feature this again with position sizing added.
      • In place of FX, I used FX futures, as I found that they mostly track very closely to spot FX. This is easier for me as I use a separate platforms for FX and futures. Now you have me thinking of doing a set with just FX.
      • Using less than a daily timeframe is always a challenge. If I were to go down to the 5-minute level, I would probably focus on very specific windows of time, such as US market afternoons, first two hours after US market open, Asian market hours, European market hours.
      • I use volume-based continuous contracts provided by my data vendor. The data is pretty clean and they are quick and responsive with data corrections.

      I really appreciate your feedback. I really just take an idea and try to interpret it as best as I can. I love your daily 40in20out updates, as they keep me level-headed about my own live trading and portfolio performance.

Leave a Reply

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