The more you grow profits, the greater the risk of loss. A story about reworking GOLD EA's take-profit.
GOLD Dedicated EA "Remanent - TENRYU -" development log, Part 3.
The first EA was a reversal strategy that activates when touching a horizontal line and takes profit when GOLD price moves 3 dollars.
If BUY, 3 dollars up; if SELL, 3 dollars down.
The rule is quite straightforward, but there is one concern.
For example, after taking profit at 3 dollars, the price may move further to 6 dollars or 9 dollars smoothly.
A method to settle everything at 3 dollars is simple, but you cannot capture movements beyond that.
So we decided to change the profit-taking mechanism.
Raising targets to 3 dollars, 6 dollars, 9 dollars
Created on September 3, 2026v0.6.5implements a staged profit-following system.
The initial target is 3 dollars.
If that level is surpassed and conditions are met, the next target is raised to 6 dollars.
If things progress smoothly, it will update to 9 dollars and beyond.
However, simply moving the TP to the next target the moment the price rises by 3 dollars is not how it works.
In the code at that time, confirmation used the closing price of the candlestick.
Even if the target is touched temporarily, if the closing price does not meet the condition, it does not proceed to the next stage.
In other words, it was not just moving the TP by 3-dollar increments; it updated targets while confirming that the price movement continued.
When trying to extend profits, another problem arises
For example, suppose a BUY position reaches 3 dollars in unrealized profit.
If you settle then, you can lock in that profit.
But if you leave the position to aim for the next 6 dollars, there is a risk of price reversing.
Even with a 3-dollar unrealized profit, it could fall to 1 dollar and then come back.
The more you try to extend profits, the more you must consider how to protect existing profits.
In the initial staged profit-taking, there was also a combination of reaching the target and candlestick confirmation.
However, subsequent modifications were made soon after.
Add a mechanism to "protect reached profits"
Next, createdv0.6.6strengthened profit protection processing.
The major change is to record that the price has reached the target, and if the price comes back, to settle at the market price.
While raising targets uses candlestick closing price, profit protection settlements are determined by price movement.
Note that this is a virtual profit protection managed inside the EA.
It does not guarantee the actual fill price.
If the price moves sharply, it may settle at a less favorable price than the planned level.
Nevertheless, this is a different approach compared to simply raising the profit target from 3 dollars to 6 dollars.
Extending profit and protecting profit.
This feature was an attempt to combine both.
Raising targets does not always increase profits
A larger take-profit width can increase profit per trade.
But the probability of reaching that price is another matter.
A 3-dollar target may be reached, but not 6 dollars.
Or it may extend to 9 dollars and then retreat significantly before reaching it.
As long as such price movements exist, simply widening the take-profit width does not guarantee higher annual profit.
This feature leads to the finished version as well
What changed from the initial EA was not only entry conditions.
Profit-taking methods also became gradually more complex.
Take only the moment when it rebounds at a horizontal line.
If the rebound continues, should we chase a bit more profit?
Meanwhile, which profits should be secured?
In discretionary trading, you can judge by looking at the market, but in an EA you must predefine the rules.
This staged profit-taking is one of those trial-and-error efforts.
And the next problem that arose was not how to take profits but how to reduce losing entries.
Capture the "shifts" born from horizontal lines and pursue the subsequent "flow."
A GOLD (XAUUSD) dedicated MT5 EA.
- Automatically detects horizontal lines and supports touches by wicks and market reversals
- As long as the market trend continues, profit follows in stages
- Fixed stop loss, time-based stop, and suppression of new entries included (martingale not adopted)
- Standard setting is 0.01 lot / Range Boost OFF
Net profit +1,242,820 yen / Maximum drawdown 24%
※Backtest results are based on historical data and do not guarantee future profits. It is recommended to verify operation on a demo account before actual use.
※This article is based on the development version source code dated September 3, 2026. The profit-following levels are differences in GOLD price, not the account's actual profit and loss.