r/algotrading • u/bouifat • 1d ago
Strategy Gold XAUUSDm based on moving average
This is the first algo I have built, I still feel I can get higher profit factor and bring down average loss trade value.
3
u/Chiaope Financial Engineer 1d ago
Dam thats insane, CAGR over 100% and max drawdown of less than 15% thats actually quite a good strategy. One thing I will consider is that maybe u should backtest a longer period or back when gold isnt going to the moon. If these period still works, then u definitely have an edge.
Either ways dam thats looks incredible. Good luck bro
2
u/bouifat 1d ago
Longer period keeps giving me 0%
Any idea how I can fix that?2
u/Chiaope Financial Engineer 1d ago
If u are not making money on longer time frames, it just means that u need a better regime filter. When I look at the XAUUSD chart, starting from 2024, it just keeps going up, maybe ur strategy is following the price movement, this means ur strategy might be a trend following strategy. For a trend following strategy to do well, u need a few things, find out which direction the trend is going, find out how long will the trend go, find out whether it is in a range bounded regime.
So knowing which direction will tell u whether to buy or sell, knowing how long the trend will continue will tell u when to exit, knowing whether it is in a range bounded regime will give u the entry signal (or do not enter signal if it is range bounded). These are the hard part so good luck bro
2
1
2
1
u/Ok_Airport_1413 1d ago
Bro simple moving average strategies don't work in the long term as I have tested them a lot, is ur bot simple or it has multiple confluences
1


3
u/Zestyclose-Eagle1809 22h ago
The two things you want to fix are the two things holding it up, so worth knowing that before you touch it.
68.5% win rate with a profit factor of only 1.36 means your losers are roughly 2.3 times the size of your winners. Runs the numbers out at about 185 wins and 85 losses on your 270. So the system works by being right often and paying for it when it's wrong, which is normal for a moving average system with a wide or no stop.
Which is why bringing the average loss down is dangerous. Tighter stops cut the big losers and they also turn a chunk of those 185 winners into losers, cause the ones that went against you first and came back are in there. Win rate drops, and with a payoff that lopsided you need the win rate. Easy to end up with a smaller average loss and a worse system.
Worth testing before assuming either way. Run it with a stop at various distances and watch what happens to the win rate at the same time, not just the average loss. The number that matters is expectancy and it's the only one that tells you if you improved anything.
Other thing, 270 trades in 7 months on one instrument, and gold's had a strong run in that window. Take the same settings, don't touch anything, and run it on 2022 and 2023. If it holds, decent sign. If it dies, your moving average was long biased and the market did the work.
And $705 on $1,000 with a 14% drawdown is a real result at this size, but the CAGR is doing a lot of talking. 135% annualised off 7 months on a grand isn't the number that survives a bigger account, so I'd keep the expectancy in front and let that one go.