Describe a trading strategy in plain language and get a working MetaTrader 5 bot back in minutes, with a backtest, without writing any code. Think "Lovable or Vercel, but for trading bots."
Live waitlist: https://waitlist.algocustom.com
This is a write-up of a product I designed and built. The source is private, so this repo is documentation only: what it does, how it is architected, and the engineering problems I solved.
demo.mp4
A trader types something like "cross of the 9 and 21 SMA on EURUSD H1, ATR stop, trailing stop." AlgoCustom turns that into a compiled .ex5 Expert Advisor, a backtest report, and a trades CSV. It can also modify, fix, and re-test existing bots.
One thing I was deliberate about: it sells the tool, not the outcome. It never promises a bot will be profitable. The value is going from idea to a runnable, testable bot in minutes instead of weeks.
- A custom MT5 bot from a freelancer costs $500 to $3000 and takes 2 to 6 weeks.
- The existing "no-code" tools are dated, low quality, or block-based.
- MetaEditor's own assistant still expects you to know MQL5.
- There was no modern "describe it, get a bot" tool for MT5, and nothing aimed at Spanish-speaking LATAM traders.
Target user: traders who have a strategy but cannot code it themselves, including people grinding prop-firm challenges.
You could ask a general AI to write the bot's code. But that leaves you with a wall of text that you still have to turn into something that actually runs. AlgoCustom does the whole job around the code, the parts a chat assistant cannot do for you:
- It compiles the bot for you. You get a real, ready-to-run MetaTrader 5 file, not code you have to set up, compile, and debug yourself.
- It reviews its own work. A second AI checks the logic for bugs and for whether it actually matches what you asked, and sends it back to be fixed before you ever see it.
- It tests the bot on past market data. A "backtest" replays the strategy over real historical prices, so you get a report and the full list of simulated trades and can see how it would have behaved before risking any money. A chat assistant cannot run your bot for you.
- It already knows MetaTrader. It draws on a knowledge base built from real MT5 support work plus a catalog of the platform's indicators, so it avoids the mistakes a general model tends to make with MetaTrader's MQL5 language.
- It remembers your bots. Your strategies, their versions, and past backtests are saved, so you can tweak and re-test instead of starting from a blank chat every time.
In short: a general AI hands you code. AlgoCustom hands you a working, tested bot, plus all the tooling around it that you would otherwise have to build and run yourself.
The core design decision is a hard split between a lightweight web app and a heavy generation worker, connected by a single clean HTTP seam.
flowchart TD
U["Trader writes strategy in chat"] --> GK{"Gatekeeper:<br/>cheap model, is it buildable?"}
GK -->|needs detail| CL["Clarification Q and A"]
CL --> GK
GK -->|yes| SPEC["Structured StrategySpec<br/>Pydantic contract"]
SPEC --> APPROVE["User approves<br/>logic summary card"]
subgraph WEB["Web SaaS - Next.js on Vercel"]
U
GK
CL
SPEC
APPROVE
CHAT["Support chat"]
end
APPROVE -->|POST spec, bearer auth| SEAM[("HTTP seam:<br/>job id + polling")]
subgraph WORKER["Generation worker - isolated VPS, FastAPI"]
SEAM --> CREATE["Creator agent<br/>writes MQL5"]
CREATE --> COMPILE{"Compile-fix loop<br/>up to 5x"}
COMPILE -->|errors| CREATE
COMPILE -->|clean| REVIEW["Reviewer agent<br/>logic-only review"]
REVIEW -->|findings| CREATE
REVIEW -->|ok| BT["Backtest<br/>headless MT5 under Wine"]
BT -->|zero trades| CREATE
end
BT --> ART["Artifacts: .ex5 + backtest report + trades CSV"]
ART --> U
CHAT --> RAG["RAG over MT5 knowledge base<br/>Postgres + pgvector"]
RAG --> CHAT
The generation pipeline is a multi-agent system built on the Anthropic Agent SDK:
- A creator agent writes the
.mq5from the spec, with file tools scoped to its own job directory. - A compile-fix loop drives the real toolchain until the code compiles cleanly.
- An independent reviewer agent checks logic only (real bugs, deviations from the spec, trade safety) and feeds findings back to the creator, which has final say. Then it loops.
- A backtest runs; a zero-trades result routes back to the creator.
- Models escalate by difficulty: a cheap model by default, a stronger one for hard compile loops or critical review findings.
The support chat answers MT5 and MQL5 questions using RAG over a curated knowledge base, stored in Postgres with pgvector, embedded with a cross-lingual embedding model so Spanish and English questions both retrieve well.
- Frontend: Next.js 15 (App Router), TypeScript, Tailwind, shadcn/ui, next-intl (Spanish first)
- Backend: Next.js API routes (serverless), no separate backend
- Hosting: Vercel
- Database / auth / storage: Supabase (Postgres, Auth with Google OAuth + magic link, Storage)
- Vector search: Supabase pgvector (HNSW, cosine)
- Generation worker: a separate Hetzner VPS running Docker behind FastAPI; Ubuntu + Wine + Xvfb running headless MetaTrader 5
- AI: Anthropic Agent SDK for code generation; the support chat is routed through Vercel AI Gateway with provider failover and a vision-capable model for image and PDF attachments
- Embeddings: Google Gemini embeddings (cross-lingual ES/EN)
- Billing: Stripe
- Tooling: GitHub, Dependabot, Gitleaks pre-commit secret scanning
A few of the harder ones, kept high level:
- Running MetaTrader 5 headless under Wine in Docker was the biggest technical risk. Logging in is not enough; the tester has to reach a "synchronized with trade server" state or it stalls. I solved it with a per-broker warm-prefix pattern: a cached, pre-synchronized environment is pulled at job start, which cut tester warmup from about 240 seconds to roughly 14. Any
.mq5becomes a compiled.ex5plus report plus CSV in about 45 seconds on a warm cache. - MetaEditor's command-line
/compile:has been broken under Wine for over a decade, so I built a compile path driven through the terminal instead. - I evaluated a serverless sandbox platform for the worker and proved its container runtime cannot run Wine (three conclusive failure modes). That killed the obvious "just use a sandbox service" approach and led me to co-host the workers on one VPS for the lowest cost and complexity.
- The worker runs untrusted, AI-generated code, so I kept it completely off the web host and ran each job in a hardened, isolated sandbox (dropped capabilities, resource caps, strict path isolation, no access to other jobs or to platform secrets). I validated the isolation with adversarial probing.
- LLM cost engineering: I pin a single caching provider per model so prompt caching actually sticks (rotating providers silently loses the cache and multiplies cost), de-escalate reasoning effort on retries, and added inactivity timeouts to tell "still generating" apart from "hung." A typical generation lands around $0.30 to $1.50.
- Cost-based metering: usage is measured by real API cost per run, not by counting generations, with a hard budget cap per run.
- The Python worker and the TypeScript app share a Pydantic DTO contract, with TS types generated from the Python models so the cross-language API never drifts.
- Full-stack SaaS (Next.js, TypeScript, Supabase, Stripe)
- AI agent engineering: multi-agent pipelines, creator/reviewer loops, compile-fix loops, model-escalation strategy
- RAG systems: knowledge-base design, pgvector, embedding-model selection, retrieval evaluation
- LLM gateway and cost optimization: prompt caching, provider failover, reasoning de-escalation
- Linux / Wine / Docker systems work: headless MT5, warm-prefix caching, terminal-driven compile
- Multi-tenant security: sandbox isolation and hardening for untrusted code, adversarial testing
- DevOps, i18n, billing design, and infra cost modeling