The EA Development Loop (2/10): Design. Write the hypothesis and the pass/fail lines before any code

22 November 2026, 17:06
Naoto Shimoda
0
18

The most common mistake I see is turning an idea into code immediately, looking at the tester result, and only then deciding what the goal was. A goal chosen after seeing the result can explain any result. So I write five things on paper first.

1. Hypothesis: which market habit are you trading?

"Buy when indicator A crosses B" is a rule, not a hypothesis. A hypothesis says why price should move, in market terms:

  • who places orders, when, and for what reason
  • on which symbol and in which hours the effect is strongest
  • when the effect should disappear

The last line matters most later. When live results break down, it helps you tell a broken hypothesis from plain bad luck.

Example: in Japan, many companies settle payments on the 5th, 10th, 15th, 20th, 25th and the last day of the month (gotobi). Importers buy dollars before the Tokyo fixing on those mornings, so USDJPY tends to be bid. Who (importers), when (gotobi mornings before the fixing), why (dollar payments) are all there. When the date falls on a weekend, the flow moves to the previous business day. That is part of the hypothesis too.

2. Conditions for not trading

These often decide how long an EA survives: news releases, the Monday gap, thin holiday markets, wide spreads, and how many positions may be open at once.

3. Exit

The exit has the largest effect on test results. Exits that depend on the order of prices inside a bar (trailing stops, take profit of a few pips, moving the stop to break-even) are badly distorted by coarse data (part 6). Note which kind your exit is.

4. Capital and lot size

Fixed or proportional lots? At what balance does the calculated lot hit the broker minimum? This matters more the smaller the account (parts 4 and 7).

5. Pass/fail lines

Decide these before the first test. My example values:

Item Example
Test period 5+ years, including years with different market character
Trades enough to read statistically
PF 1.3 or more on real ticks
Max drawdown within 30% of capital, including floating loss
By year no run of losing years

Why 30%? After a 30% loss you need +43% to recover (1 / 0.7 = 1.43). Even at 3% a month compounded, that takes about a year.

Write the spec as states

[Waiting] --entry--> [In position] --exit--> [Waiting]
    |                      |
    +--no-trade-->[Paused]  +--stop line--> [Waiting]

A state-based spec leads directly to "recover the state from open positions after a restart" (part 4).

Keep inputs few

The more inputs, the easier it is to find a combination that only fits the past (part 8). In my own products the inputs a customer chooses are usually just a multiplier and a few others.