This strategy trades PAXG, a token backed by gold, as a perpetual future on 4-hour bars. It is always fully long or fully short, and it switches sides only when price moves a wide, volatility-based distance against it. It traded only inside two date ranges written into the code. The backtest ran from April 2025 to November 2026. It made 42.1%. Holding PAXG for the same period made 13.7%.
The core rule is simple and worth studying. The date ranges are the weak point, and they are also the most useful lesson on this page.
How it works
The strategy is a stop-and-reverse system. It always holds a side, and it always has one price level that would flip it to the other side.
- Measure volatility. ATR(14) is the average true range over the last 14 bars, which is about 2.3 days of 4-hour bars. It tells you how far gold usually moves in one bar.
- Set a stop when the side changes. A long position gets a stop 2.5 ATR below the closing price at the flip. A short position gets a stop 2.5 ATR above it.
- Keep the stop where it is. The stop does not trail behind price. It stays at the level set at the flip.
- Reverse on a close through the stop. If a 4-hour bar closes at or past the stop, the strategy flips to the other side with 100% of equity and sets a new stop.
- Trade only inside the windows. The code allows trading from 27 Aug to 26 Nov 2025 and from 9 Dec 2025 to 5 Mar 2026. Outside these dates it closes its position and stays flat.
Here Cflip is the close of the bar where the position last changed side.
The code has one more detail. On every bar it replays the rule over the last 340 bars, which is about 57 days, and the replay always starts long. The position it holds is wherever that replay ends. In a rising market the replay stays long, so the strategy was long almost all the time.
Results
+42.12%
Annual return
+24.02%
1.26
Max drawdown
15.33%
| Buy-and-hold PAXG, same period | +13.7% |
| Trades | 14 |
| Average long exposure | 29.7% of equity |
| Average short exposure | 0.7% of equity |
| Funding paid | −3.1% |
| Fees paid | −0.5% |
| Liquidations | 0 |
Why it works
Gold trended hard in the two windows. The stop sits 2.5 ATR from the entry and never moves closer. In a steady trend, normal pullbacks almost never reach it, so the strategy stays in the trade and keeps the whole move. That is how one position can make more than 10% in a single month.
It was really a long-only strategy. The average long exposure was 29.7%. The windows cover about 30% of the backtest, so the strategy was long for almost all of its active time. Short trades were a small part of the result. In this test the reversal rule mostly did one job: it kept the strategy long while gold rose.
The windows did most of the work, and they used hindsight. The strategy made 42.1% while buy-and-hold made 13.7%. The difference comes from being flat in every month outside the windows. But the dates are typed into the code, and the code calls them "identified trending" windows. A trader in August 2025 could not have known that gold would trend until early March 2026. So read the 42% as the best case for this rule, not as a forecast. The return is real for those dates, but nobody could have chosen those dates in advance.
Costs were small, but holding long costs money. Fourteen trades cost only 0.5% in fees. Funding cost more, at 3.1%, because long perpetual positions usually pay funding. A strategy that stays long for months should count this cost.
Make it your own
The useful part is the stop-and-reverse rule. The question to test is whether it can find gold's trends without help from the calendar. Here are two ways to find out.
1. Replace the calendar with a trend filter
ADX is a common indicator of trend strength. Let ADX decide when to trade, instead of fixed dates. If the rule still beats buy-and-hold, the idea works without hindsight.
2. Let the stop trail and trade all the time
Here the stop follows price, so the strategy keeps more of each trend when the trend turns. The strategy also trades every bar, with no dates and no filter. This is the strictest test of the rule.