A Robust and Simple Addition to a Diversified Portfolio
We are all about turning complex ideas and patterns into straightforward, rules-based strategies that anyone can understand. Today, we want to show you a simple yet powerful trend-following bond trading strategy that focuses on the U.S. 2-Year Treasury Notes (often called “2-Year T-Notes”).
Historically, 2-Year T-Notes have shown resilience and even delivered profits when the stock market has faced headwinds. By systematically following trends on a monthly timeframe, we aim to filter out the day-to-day noise and focus on catching the bigger swings that can easily be seen in bonds. In this post, we’ll break down the logic behind our code and the key indicators used. The goal is to ensure that by the end, you will have a unique strategy that can serve as a valuable addition to your portfolio, especially when stocks fail to deliver.
Understanding the Market & Timeframe
What are 2-Year T-Notes?
2-Year U.S. Treasury Notes are short-term government bonds backed by the U.S. government. They’re considered relatively low-risk, interest-rate sensitive, and often behave differently than stocks. While equities can be turbulent, T-Notes can provide stability and diversification. When stocks are weak, these bonds can shine, making them a strong candidate for traders looking to smooth out returns with trend-following bond strategies. If you want to know more you can read What are bonds and how do they work?
Why Monthly Timeframe Trading?
One of the keys to this strategy is using monthly price data. Shorter timeframes can lead to excessive noise and constant whipsaws. By zooming out to a monthly chart, we filter out small, meaningless fluctuations. This allows us to identify genuine and strong trends.
Trend-Following Bond Basics
At its core, trend-following is about riding the market’s long-term movements. Instead of predicting where prices will go, we wait for confirmation that the market is moving in a certain direction. In the bond market, identifying trends can be easier than you’d think, and that’s exactly what our trend-following 2-year treasury strategy is designed to do.
Here is the backtest from June 1st, 1990 to November 1st, 2024:
Backtest Setup for 2-Year T-Note Trend-Following Strategy
Market: 2-Year T-Note Futures (2$)
Contract: 1 Contract with 2$ per point
Broker: IG
Testing environment: ProRealtime 12
Timeframe: Monthly
No fees and commissions are included.
Result
Total gain: 5 616 $
Average gain: 133.71 $
Total trades: 42
Winners: 17
Losers: 25
Breakeven: 0
Winrate: 40%
Max drawdown: –1072.2 $
Risk/reward ratio: 4.78
Total time in the market: 76.2 %
Average time in the market: 161 days, 6 hours
CAGR (10 000 € in starting capital): 1.28 %
Entry Conditions
Long Entry
Close is above MA[10]
RSI[2] (close) is above 80.
Short Entry
Close is below MA[10].
RSI[2] (close) is above 30.
Exit Conditions
Long Exit
Close is below MA[10]
Short Exit
Close is above MA[10]
Code
ProRealTime
//-------------------------------------------------------------------------
// Main code : TF 2-Year T-Note Monthly
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Concept: Trend Following
// Market: Bonds
// Direction: Long/Short
// Timeframe: Monthly
// Timezone: CET
// Versions: v.0.1 | Algomatictrading.com | 2024-11-05
//----------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
MA10 = Average[10](close) //default 10
c1 = (close > MA10)
c2 = RSI[2](close) > 80 //default >80
IF c1 and c2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
c3 = (close < MA10)
IF c3 THEN
SELL 1 CONTRACT AT MARKET
ENDIF
//SHORT SIDE
c4 = RSI[2](close) > 30 //default > 30-50
// ENTRY SHORT
IF close < MA10 and c4 THEN
IF NOT shortonmarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
ENDIF
// EXIT SHORT
IF close > MA10 THEN
EXITSHORT 1 CONTRACT AT MARKET
ENDIF
Pros and Cons of This Strategy
Pros:
Simplicity: Easy to understand and implement.
Long/Short Capability: Able to profit from both rising and falling markets.
Robustness: Using monthly data reduces noise and enhances reliability.
Could be tweaked a little to be traded on many commodities/bond markets.
Has been performing very well historically in weak stock market periods.
Cons:
Fewer signals due to monthly timeframe.
May miss smaller opportunities due to simplicity.
Requires patience, as trades are not frequent.
Has a quite high time in the market because of long holding periods.
Potential Improvements & Next Steps
Adjusting Parameters
Experiment with different MA lengths or other kind of filters.
Tweak RSI thresholds to match market volatility.
Risk Management
Add stop-loss rules or position sizing techniques.
Consider diversification across multiple markets.
Backtesting & Validation
Always use robustness tests before deploying. You can find some examples HERE.
Test with a demo account to gain confidence.
Remember to sign up on our email list at the bottom for another FREE Trading strategy.
FAQ
Q: Am I free to use this strategy however I want?
A: Sure! But we're happy if you refer to our website and keep the creator's name in the code.
Q: I'm using another platform, can you write the code in another language?
A: No, sorry. We might add code in more languages later to the website, but until then, we recommend you try ChatGPT or something similar to help you rewrite it.
Q: Why does my backtest look different when I run the code?
A: The strategy might give different backtest results for several reasons, like added spread or fees, the wrong time-zone settings, or that you're using another type of contract/instrument type.
Q: Will I make money if I run this strategy live?
A: We don't know. We're not financial advisors, we're just traders sharing our ideas.
We would love to hear about your modifications and custom versions of this strategy.
Feel free to mail us at: algomatictrading@gmail.com
Or message us on X: https://x.com/AlgomaticTrade