Just increased the number of horizontal lines to four. The surprising difficulty I faced in EA development
GOLD-only EA "Remanence - TENRYU -" development log, Part 2.
The first EA I made drew one horizontal line each from the most recent high and low, and simply did counter-trend trading when price reached those lines.
One resistance line and one support line.
A total of two horizontal lines, a fairly simple mechanism.
From there I progressed development and on September 3, 2026 I increased the horizontal lines to four.
At first glance it looks like only adding two more lines, but within the EA, the amount of management suddenly increased.
Why four horizontal lines
In discretionary trading using horizontal lines, you don’t just look at the nearest high or low.
Highs and lows formed a little earlier can also be candidates that the price might react to.
However, the initial version of the EA only managed the latest resistance and support.
When a new high or low is confirmed, the reference horizontal line gets updated.
Then you can’t sufficiently verify entries using lines from a little earlier.
So I createdv0.6.1.
The latest resistance is R1, the one before it is R2.
Likewise for the supports: S1 and S2, totaling four entry candidates.
However, it wasn’t just about increasing the visible lines.
Which horizontal line did you enter on
With multiple horizontal lines, you need to manage which line the price reacted to.
For example, if price levels R1 and R2 are very close.
Even if both meet entry conditions, you’d want to avoid placing two SELL orders at the same time.
So I added a mechanism to prioritize the line that is closer to the current price when multiple lines become candidates simultaneously.
Also, when adjacent lines of the same direction are close, I added a filter to exclude the older line from the entry targets.
The setting value at that time was 0.50 dollars for GOLD price.
However, this is not about completely removing the old lines from the chart; it is a process to organize entry candidates when lines are close.
Having more horizontal lines does not necessarily confer an advantage.
That was the fix to address such issues.
How many times did you enter on the same line
Another requirement was managing the number of entries.
From the initial version there was a rule of up to three entries per line.
But with four lines, you must manage the count for each line individually.
Furthermore, if price comes close to the same horizontal line repeatedly, you need re-entry conditions and cooldown to prevent unlimited orders.
With the then settings, you could re-enter once price moved 0.50 dollars away from a line, and proximity within 0.25 dollars to a line counted as an entry candidate.
Cooldown is three candlesticks.
On an M5 chart, that corresponds to 15 minutes.
These rules were managed for each horizontal line.
So you can understand what happened by looking at the order history
v0.6.3 added a feature to record the entered horizontal line in the order comments.
Furthermorev0.6.4 now records which entry number it was as well.
For example,
BUY_S1_E1: First BUY from S1BUY_S1_E2: Second BUY from S1SELL_R2_E3: Third SELL from R2
that’s how it works.
It’s a small change, but helps when analyzing backtests later.
Is the profit coming from R1 or R2?
Do the first and third entries perform differently?
To investigate such questions, you need to categorize the trades first.
Later, this allowed detailed performance analysis by horizontal line, thanks to such records.
Just increasing logic won’t make it an EA
At this stage, the profit target was still basically fixed at 3 dollars.
There was no Role Reversal, and no long-term trend filter added later.
What I did was increase the horizontal lines and organize the entry mechanism.
In EA development, people often focus on new trading logic.
But in reality, it’s also important to avoid overlapping orders and to be able to verify the reasons for entries later.
Increasing horizontal lines from 2 to 4, I think, was the stage where I built these fundamental parts.
Capture the “turn” born from the horizontal lines and follow the “flow” that continues beyond it.
A GOLD (XAUUSD) dedicated MT5 EA.
- Automatically detects horizontal lines and handles contact via wicks and roll reversals
- As long as the market trend continues, gradually follow profits
- Fixed stop loss, time-based exit, and new-entry suppression (Martingale not used)
- Standard setting is 0.01 lot / range boost OFF
Net profit +1,242,820 yen / Maximum drawdown 24%
※Backtests are results of historical data verifications and do not guarantee future profits. It is recommended to verify operation on a demo account before actual use.
※This article records development code as of September 2026. The numbers appearing are from test configurations at that time and may differ from the current retail version settings.