In today`s example we want to back-test a basic trading strategy for the gold market using a trend filter (SMA) and an overbought/oversold indicator (RSI). Additionaly, a time exit will be used to close a position.
Strategy Rules: Buy on Weakness in a Bull Trend
The rules for this basic approach are pretty simple. First, we want to define whether gold is in an uptrend or downtrend. The easiest way to quantify this is using the SMA. The second component is defining a correction. In this example I rely on the RSI oscillator.
So here is the pseudo code for the strategy:
- If the gold price is above its n-day SMA (signals a bull market) AND
- the RSI is below X (signals a correction)
then we enter a long position. Opposite rules apply for the short side.
For each trade, the same amount of 100k will be invested (no compounding). If the holding period exceeds n bars (we use a weekly chart here), then the position will be closed.
Backtest Results for Gold
Here are the results from 2011 to today using cash prices and following parameters:
- SMA: 100 (around 2 years)
- RSI Period: 2 with 80/20 threshold
- Time Exit: 4
- Costs: not included
I picked this period because during that time the gold price – on net – went nowhere. That`s a good comparison period between a passive buy and hold approach and our systematic trading strategy.
And here is a zoom into the signals generated in the last 2 years.
Tradesignal® is a registered trademark of Tradesignal GmbH. Unauthorized use or misuse is strictly prohibited. Data by Thomson Reuters Eikon.