D-Zero

Strategy Architecture: Building a Testing Engine with Logic Gates

Written by D-Zero News | 19/03/26 15:14

Strategy Architecture: Building a Testing Engine with Logic Gates

Most algorithmic traders build a strategy, run a backtest, and hope for a green equity curve. If it fails, they rewrite the code and try again.

This is highly inefficient. Professional systematic traders do not just build trading bots. They build testing engines.

In our latest Strategy Development session, we took a standard technical concept and engineered it into a dynamic, highly testable framework.

Here is the technical breakdown of the architecture we built, and why it is the necessary foundation for robust strategy optimisation.

1. The Base Logic: The Kangaroo Tail

To demonstrate this architecture, we required a base execution model. We used a daily timeframe breakout strategy known as the "Kangaroo Tail".

The premise relies on a three-candle fractal swing.

  • The Setup: Yesterday's low is higher than the day before, which is lower than the day before that. This forms a "tail" rejecting lower prices.
  • The Execution: The algorithm places a Buy Stop pending order at yesterday's high.

We programmed this to execute at a specific time (01:05 broker time) on USDJPY. Untriggered pending orders are programmed to expire automatically at the end of the daily session.

2. Engineering On/Off Logic Gates

A base entry model is rarely profitable in isolation. It requires dynamic filtering.

The standard retail approach is to code a moving average filter, run a test, realise it fails, delete the code, and write an ADX filter. This wastes time. Instead, we wired On/Off Gates directly into the algorithm's architecture.

We built independent switches for an ADX filter and a Moving Average filter. We programmed logic that allows the user to toggle these filters on or off directly from the MetaTrader inputs tab. You can also dictate whether the price needs to be above or below these filters without touching the source code.

This means you can drop the single compiled file into your Strategy Tester. The software then rapidly cycles through every combination of filters, periods, and thresholds automatically. You build the environment once. The machine does the heavy lifting.

3. The Curve-Fitting Trap

By the end of the session, we had a fully functional, highly optimisable MQL file. But an optimisable file is dangerous if you do not understand statistical variance.

If you run an optimiser across enough variables, the machine will eventually generate a perfect equity curve. It will find the exact historical parameters that would have made you rich over the last five years.

This is curve-fitting.

A curve-fitted strategy has no genuine alpha. It is an illusion of past data, and it will collapse the moment it touches live, unseen market conditions.

Part Two: The Optimisation Masterclass

Building the code is only 10% of the work. Stress-testing it to ensure the edge is robust is the other 90%.

On Tuesday, March 24th at 4:00 PM UK time, we are hosting Part Two of this series.

Martyn Tinsley, manager of DARWIN: TRO and creator of Opt My Strategy, will take the raw file we built in Part One. He will demonstrate his professional framework for optimising a strategy robustly, identifying genuine alpha, and avoiding the trap of over-fitting.

If you want to understand how a portfolio manager validates a system before allocating real risk, this session is required viewing.

Watch Part One ðŸ‘‡

 

Set a Reminder for Part Two (next Tuesday) here 👉 Optimising with Martyn.

 

Thanks for reading,
Darwinex Zero.


*Darwinex Zero and the domain www.darwinexzero.com are trade names used by Tradeslide Technologies, a company registered in the United Kingdom under number 14398381.

The contents of this blog post are for educational purposes only and should not be construed as financial and/or investment advice.