#16 Optimizing Trailing Stop to Achieve PF1.99! However, the wall of the "target" stands in the way
November 19, 2025: Note
This is a progress report on the development of the EA (Expert Advisor).
今回は、ロジックの致命的な問題が発覚したにもかかわらず、パラメータの最適化によって予想外の成果が出た話と、手動トレード手法をEAに落とし込む際の根本的な問題点について深く掘り下げていきます。
Fatal bug discovered!
Transition to Simple Pips Close and the Shock of PF1.99
In this EA development, a very important fact has become clear.
Actually, the trailing stop logic that was embedded in the EAwas not functioning properly due to a fatal bug.
・ The trailing did not function because of the fatal bug.
・ Nevertheless, the PF exceeded 1 (i.e., there was profit).
It was fortunate that this bug was found, but the fact that profits were appearing even when the trailing stop was not functioning may suggest the strength of the underlying entry logic.
Therefore, I decided not to fix this bug, but to switch to a simpler and more reliable logic.
“Close when the latest candlestick close price exceeds (or breaches) the previous candlestick close price”, a complex and difficult-to-implement logic, was discarded, and I changed to a simple logic that closes by profit width specified in Pips (or manages with a Pips-based trailing stop).
Results of Parameter Optimization
After this simple logic change, I conducted a combined test (optimization) of the parameters LC (trailing stop interval) and TP (profit width to start trailing stop) in the range of 30–60 Pips.
As a result,the PF (Profit Factor) over 3 years reached 1.99, with an excellent parameter combination found (髭剃り手法_表版: TP=40, LC=30).
However, another test case showedthat profits were only around 150,000 yen turning into 145,000 yen over three years
This is far better than a mutual fundin performance, but for FX traders who love high leverage, it remains unsatisfactory at the current level.
To reproduce the ideal PF of 1.99 reliably, further verification is necessary.
The biggest obstacle to reproducing the manual “髭剃り手法”: Definition of the “Target”
Temporary gains were achieved via parameter optimization, but the biggest issue preventing my manual goal of thehair-cut method from approaching the current EA logic lies in how the “target” is defined.
In the manual “髭剃り手法,” the setup assumes waves like the following:
1. A big wave that exceeds the previous cycle’s peak (target) forms,
2. It is entered when it enters the downward phase (Elliott Wave 4th or 5th wave)
In other words, the “target” must be a clearly defined peak from the previous cycle.
Disparity between EA logic and manual logic
However, the current EA source code is coded as follows.
To treat as “target” the highest candlestick within a certain number of bars from the current wave
The problem with this logic is that the EA recognizes as the “target” the candlestick of the second or third wave that is currently forming within a large wave.
This is completely different from the “peak of the previous cycle” that we actually want to target.
The manual “髭剃り手法” cannot be reproduced by the EA due to this misrecognition.
Question to the program
To solve this problem, the EA needs to recognize“the clear peak of the previous cycle”.
In the program, what code would accurately capture the large wave of the cycle and seize the “real target”?
〇 Instead of searching for the highest price up to a certain past bar, a fundamental reconstruction of the logic is necessary.
Next time:
Can the program capture the large wave?
Next time, focusing on thedefinition of the “target”, we will examine concrete logic ideas on how to translate manual trade recognition into code.
We will pursue the ideal logic without settling for PF1.99 as the final result.
Stay tuned!
※
The EA I am developing is intended to automate what is described in Episode 2, which is something anyone can achieve manually
“A method that wins even with scalping prohibition”that I am working on automating.
This is the only paid article in this series (so far).
150 yen!So cheap!... President, so cheap! ٩(ˊᗜˋ*)و
× ![]()