#15 The secret to perfect victory was a "deadly bug"?!
November 16, 2025: Note
In the previous issue, we examined the mystery of the "last major drawdown" that appeared in the three-year continuous graph of the strongest candidate "Behind Version 1H / 1M".
"In favorable markets I dominate, so why do I lose over three years?"
I hypothesized that the cause lies in the EA's weakness during the “gap period” where it tends to lose steadily.
However, behind that premise,"Are M1 settlements (stop losses on the 1-minute chart) perhaps too sensitive?"was a hypothesis.
So I decided to verify that hypothesis first.
Headline: Test for three years with settlement on the "5-minute chart"
Could it be that the M1 ("1-minute") settlements are too sensitive, getting shaved by small noise (steadily losing) and failing to grow profits?
With that in mind, I changed the settlement to"M5 (5-minute chart)"and conducted another three-year continuous test using combinations with the base charts (daily, 4-hour, 1-hour).
The result was……
Total wipeout.
♪ Zanzan ♪ ( ´´ิ∀´ิ`三´´ิ∀´ิ` )
In all combinations, the PF (Profit Factor) fell below 1.0, ending in a total three-year loss.
Headline: For some reason losses concentrated on weekends
I stared at the results of this “M5 settlement test” and was at a loss.
However, when I scrutinized the detailed report, I noticed something odd.
"Why do losses somehow cluster on weekends…?"
This EA includes logic to forcibly close positions on Friday night (or early Saturday morning) to avoid huge losses from the opening gap at Monday start.
Many of the losses from M5 settlements were caused by this [weekend forced settlement], producing large losses.
Headline: The biggest question: "Why doesn't the stop-loss trail work?"
Here I encounter the central question.
Why does the [price-based stop-loss trail] not work in both M1 and M5 settlements, leaving positions to the weekend [forced settlement]?
Poster version (sell) is defined as, when the settlement candle's close exceeds the high of the previous candle, it triggers a stop/profit?
Behind version (buy) triggers a stop/profit when the settlement candle's close falls below the previous candle's low?
This is the logic.
On such a fine chart as M1 or M5, could it be that this condition would not be met for a week (three years!)?;
Even if the price moved slowly in the reverse direction, it should at some point update the previous candle's high/low.
This is far more than just losing slowly.
Perhaps the stop-loss (trail profit) logic itself is not functioning?
Shocking bug discovered
I revisited the EA's source code from the beginning.
And then…
I discovered a colossal bug.
This EA used the “M1 (1-minute) confirmation” as the basis for all processing instead of OnTick() (tick data).
The problem lies in the trailing stop logic.
If the settlement basis is set to M1,
it compared the “closing price one bar before M1” and the “real low (or high) one bar before M1.”
In other words…
- It required the prior M1 bar's real low to be lower than the prior bar's real low
- It required the prior M1 bar's real high to be higher than the prior bar's real high
which was an absolutely impossible conditionto satisfy.
The true reason for all wins
This means only one thing.
If the settlement is set to M1, the stop-loss-based profit-taking (trail) never actually triggers.
Remarkably, the previously celebrated “all wins” and the astonishing PF of 19.12 were achieved in a state where the stop-loss trail did not function at all, relying only on the first +30 pips profit from partitioned settlements!
And the positions that never reached the initial profit point were left as “zombie” positions until the weekend, and caused huge losses like -46 dollars or -139 dollars due to [weekend forced settlement]…
That was the answer to all the mysteries.
Improvements found
It was good that there was a bug! (lol)
Now what I must do is clear.
The complex trailing based on candlesticks was the hotbed of this bug.
I will stop the annoying stuff. (lol)(lol)
Headline: Improvement: Do not use candlesticks for trailing stops. Simply specify in pips.
With this, the source code becomes simpler and the trail will reliably function!
Next:
Finally implementing the true safety device: fixed stop loss (LC)!
Profit taking (TP), stop loss (LC), and the base chart…
The final optimization test to find the strongest "golden ratio" begins!
… planned (^_^;)
※
The EA I am developing is automation of the “method that can be won even with scalping prohibited,” introduced in Episode 2 and manual implementation by anyone.
"A method that can win even without scalping"is what I am automating.
This series' (so far) only paid article.
150 yen!Cheap!... President, cheap! ٩(ˊᗜˋ*)و
× ![]()