DEV Community

Palak Sinojia
Palak Sinojia

Posted on

BacktestLab: Turn MT5 Optimization Chaos into a Reproducible Research Library

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission đź’¸

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle.

What I Built

My father has been trading for years.

On his days off from his office job, our house often fills with friends who come to learn from him, discuss strategies, and trade together.

Growing up around this, I saw how much experimentation goes into developing a trading strategy.

But one day, my father showed me something surprisingly simple: his notebook.

Inside were handwritten strategy configurations—RSI settings, EMA values, ATR parameters, stop-loss and take-profit levels, and notes about different approaches he was testing.

He explained how tedious it was to review backtest results, identify promising configurations, and manually record the ones worth keeping.

And I started wondering:

Why was someone running sophisticated trading experiments still managing the results by hand?

That question became BacktestLab.

BacktestLab is an open-source, AI-assisted research manager that transforms raw MetaTrader 5 (MT5) optimization results into an organized, searchable library of experiments.

Instead of manually reviewing every optimization pass, traders can import their results, automatically identify configurations that meet their research criteria, and understand why particular experiments qualified or failed.

BacktestLab has five core capabilities:

  • MT5 Import: Turn supported optimization exports into structured experiment records, including Win Rate data from a matching companion CSV.
  • Automatic Qualification: Identify promising configurations using consistent, deterministic performance rules.
  • Experiment Explorer: Search, filter, and inspect individual experiments and their parameters.
  • Research Autopsy: Examine qualification outcomes and the evidence behind each decision.
  • Local Gemma Interpretation: Generate readable, evidence-linked research commentary using an open-weight model running locally.

It helps traders make sense of the research they've already done.

The Side Hustle Opportunity

BacktestLab is built for independent algorithmic traders, Expert Advisor developers, and small trading-research teams who repeatedly optimize strategies.

Their problem isn't a lack of data. It's having hundreds or thousands of experiments without an efficient way to identify, organize, and revisit the useful ones.

The current open-source version establishes the foundation: MT5 ingestion, automatic qualification, searchable experiment records, Research Autopsy, and local Gemma interpretation.

But I also see a path toward turning it into a sustainable product.

The idea is to keep the core research engine open source while offering a paid, ready-to-use desktop edition. Traders could install BacktestLab and start organizing their research without setting up a development environment.

Over time, a premium edition could introduce:

  • Custom qualification rules: Let traders select their own performance metrics, define thresholds, and save different evaluation profiles for different strategies.
  • Cross-batch AI analysis: Use Gemma to compare optimization runs, surface recurring parameter patterns, and summarize research progress.
  • Research reports: Generate exportable experiment summaries and maintain a more complete history of strategy development.
  • Team research workspaces: Allow small trading teams to share experiment libraries and review results together.

The business opportunity isn't about selling trading signals or promising profitable strategies.

It's about selling convenience, organization, and time saved to people who already invest significant effort into trading research.

And because Gemma runs locally, AI-assisted analysis could remain cost-efficient while keeping sensitive strategy data under the researcher's control.

Demo

From raw optimization results to organized research.

The demo walks through BacktestLab's workflow: importing MT5 optimization data, reviewing qualification results, exploring individual experiments, and using Gemma for local AI-assisted interpretation.

Research Autopsy:

BacktestLab Research Batches dashboard

To demonstrate BacktestLab's research workflow, I tested it with both real MetaTrader 5 optimization results and a larger sample dataset.

1. Real MT5 Optimization — 5 Experiments

BacktestLab Research Autopsy showing 5 real MT5 experiments, with 3 qualified and 2 rejected

I imported an actual MT5 optimization XML report alongside its matching Win Rate companion CSV.

BacktestLab validated the data, evaluated all five experiments against the qualification criteria, and produced:

  • 3 qualified experiments
  • 2 rejected experiments
  • 0 incomplete experiments

This demonstrates the complete workflow using actual MT5-generated optimization data, including the Win Rate information needed for qualification.

2. Larger Sample Dataset — 100 Experiments

BacktestLab Research Autopsy showing 100 sample experiments, with 69 rejected and 31 incomplete

I also imported a sample XLSX dataset containing 100 optimization experiments to test how BacktestLab handles a larger collection of results.

The Research Autopsy produced:

  • 0 qualified experiments
  • 69 rejected experiments
  • 31 incomplete experiments

All 100 experiments lacked Win Rate information. Rather than assuming missing values were acceptable, BacktestLab rejected experiments that failed other required criteria and marked the remaining experiments as incomplete.

The Research Autopsy also surfaced recurring findings, including low profit factor, excessive drawdown, and missing Win Rate data.

Together, these tests demonstrate that BacktestLab can evaluate complete real-world MT5 data while also handling larger, incomplete research datasets without hiding missing information.

Local Gemma Interpretation

Local Gemma 3 4B interpretation showing low profit factor findings and supporting experiment evidence

Gemma generates research commentary linked to deterministic findings and individual experiment records.

The screenshot shows an actual response generated by Gemma 3:4b, running locally through Ollama.

The interpretation identifies a low-profit-factor finding, links it to supporting experiment records, and suggests a follow-up question for further investigation.

Code

GitHub Repository: https://github.com/palak1-2/BacktestLab

BacktestLab is open source. The repository contains the Python backend, React frontend, automated tests, and MT5-related experimental tooling.

How I Built It

1. Turning MT5 exports into structured experiments

BacktestLab uses Python, FastAPI, and SQLite for ingestion, validation, evaluation, and research storage.

MetaTrader 5 optimization reports contain individual passes with different parameters and performance metrics.

BacktestLab parses supported exports and stores the results as structured experiment records, making them searchable and easier to revisit.

One interesting engineering challenge was Win Rate.

The required Win Rate metric wasn't consistently available in the optimization exports I was working with.

Rather than silently skipping it or making assumptions, I developed a companion CSV workflow using an MT5 Expert Advisor proof of concept.

BacktestLab validates the companion data against the optimization passes before combining them.

This allows the qualification engine to work with complete, consistent inputs when the necessary metrics are available, while explicitly identifying missing information otherwise.

2. Deterministic qualification

Every experiment is currently evaluated against three explicit criteria, based on the research requirements that originally inspired BacktestLab:

Metric Qualification rule
Profit Factor Greater than 1.5
Equity Drawdown % Less than 25%
Win Rate Greater than 60%

An experiment qualifies only when all three requirements pass.

If a required metric is missing, the system identifies insufficient data rather than inventing a result. If a required rule fails, the experiment is rejected.

These are the starting rules, not a universal definition of a good trading strategy.

As BacktestLab evolves, I want researchers to create their own qualification profiles—choosing metrics, defining thresholds, and applying different rule sets to different trading strategies.

The underlying principle will remain the same:

The same inputs and criteria should always produce the same qualification decision.

The validated 100-experiment sample batch demonstrates how the evaluation system handles a larger dataset, including failures and incomplete information.

3. Research Autopsy: Understanding the decisions

A simple pass/fail label isn't enough when someone is investigating strategy performance.

BacktestLab's Research Autopsy brings together qualification outcomes and supporting evidence.

Researchers can examine which criteria passed, which failed, and where required information is missing.

It also presents failure patterns, metric distributions, and descriptive parameter-group associations.

Instead of asking, “Which experiment looks good?”, a researcher can ask:

“Which experiments met my criteria, and what evidence supports that decision?”

This turns a collection of backtest runs into a more useful research record.

4. Adding local AI with Gemma

For the AI layer, I integrated Gemma 3:4b through Ollama, running locally.

Gemma receives structured research information, including metrics, parameters, qualification outcomes, and rule-evaluation evidence.

It produces a natural-language interpretation to help the researcher understand the results without manually piecing together every metric.

In one actual interpretation, Gemma identified low profit factor as a concern.

Its executive summary was:

Low profit factor

It also generated a grounded observation:

The strategy demonstrates a notably weak profit factor.

The interpretation linked that observation to deterministic finding F-001 and the relevant experiment records.

Gemma then suggested a follow-up research question:

Does a low profit factor consistently emerge from this strategy?

This is exactly the role I wanted Gemma to play: helping a researcher interpret evidence and identify what to investigate next.

The separation of responsibilities is intentional:

  • Python decides: Parsing, validation, thresholds, and qualification.
  • Gemma explains: Research-oriented interpretation of the resulting data.

Gemma doesn't override the qualification engine, guarantee future performance, or execute trades.

The application also makes the limitations of AI interpretation visible. For example, when the input is bounded to fit the model's context limits, the interface explicitly notes that only selected findings and parameters were evaluated.

Running Gemma locally has practical advantages, too. Traders can work with proprietary strategy research without sending it to a hosted inference API, and repeated interpretations don't generate per-request API charges.

5. Building the research interface

The frontend uses React, TypeScript, and Vite, with a charcoal, ivory, and amber visual identity.

I organized the experience into four main pages:

  • Import: Bring MT5 optimization results into the system.
  • Research Batches: View and revisit imported datasets.
  • Experiment Explorer: Search, filter, and inspect experiments.
  • Research Autopsy: Review qualification evidence and optional AI interpretation.

I also built automated backend tests and tested the ingestion workflow using actual MT5 optimization exports.

The goal wasn't just to make an attractive dashboard. It was to build something that could work with the kinds of reports that inspired the project.

Why Does Open Innovation Matter?

BacktestLab started with a specific problem: helping someone manage the growing history of their trading experiments.

Open-source technology made it possible to build a solution around that workflow without relying on a closed AI service.

Gemma and Ollama made local AI interpretation practical.

That matters for three reasons.

Privacy and control: Trading strategies, parameter configurations, and optimization results can be sensitive research assets. Local inference keeps the interpretation workflow on the researcher's machine.

Freedom to experiment: Using an open-weight model gives developers greater control over prompts, inference settings, and how AI fits into the application.

Transparent decision-making: BacktestLab's qualification logic is ordinary, inspectable Python code. Researchers can understand why an experiment qualified rather than trusting an opaque AI judgment.

Open innovation also means the project can grow beyond my father's workflow.

Other developers can inspect the code, adapt the research rules, improve MT5 compatibility, or experiment with different local models.

For me, the value of open-source AI isn't simply that the model is available.

It's that I can build AI around a real problem while keeping the important decisions understandable and under my control.

My First User

My first user was also the person who inspired the project: my father.

He's spent years trading, experimenting with strategies, and sharing what he's learned with friends and family.

When he tried BacktestLab, the feature he appreciated most wasn't the dashboard design or even the AI.

It was the automatic identification and storage of useful experiments.

That was the exact repetitive task he'd been doing manually in his notebook.

He also tried Gemma's interpretation feature and thought it was fine. But his strongest reaction was to the practical benefit of keeping promising configurations organized without manually recording each one.

That feedback taught me something valuable.

As developers, it's tempting to think the most impressive feature is the one using AI.

But sometimes the feature that matters most is the one that removes an everyday frustration.

I haven't made a sale yet, and BacktestLab is still at the beginning of its journey as a potential side hustle.

But having the person who inspired the idea actually try the application—and appreciate the problem it solves—was a meaningful first step.

I started with a notebook full of trading experiments. I ended up building a research tool that could make that notebook a little less necessary.

Prize Categories

Best Use of Gemma

BacktestLab integrates Gemma 3:4b through local Ollama inference to provide evidence-linked, AI-assisted interpretation of MT5 optimization research, while keeping experiment qualification reproducible and deterministic.


Top comments (0)