You described the strategy in plain English — something clean, something reasonable:
Buy when momentum turns up after a pullback.
Exit on a trailing stop.
Avoid chop. Risk small.
ChatGPT or Claude wrote the Expert Advisor. The code compiled. The comments looked professional. The inputs were neatly named. You dropped it into the Strategy Tester, and there it was — the staircase. A clean equity curve, tiny drawdown, a win rate that made your chest feel warm. A backtest so pretty it looked like it had a skincare routine. You sat there thinking: I just built a money printer in an afternoon.
Then you went live. Week one was flat. Week two bled. Week three looked nothing like the backtest. Now you're staring at two curves — a smooth staircase up in the tester, a slow leak down in your account — from the same bot, same rules, same symbol, same timeframe, living in two completely different universes.
Here's the part almost nobody tells you. The code might not be broken. It might be worse: it might be reading the future. Somewhere inside those clean lines, the AI wrote logic that works beautifully in a backtest because the backtest already knows something the live market doesn't:
- the close of the current candle
- the future value of an indicator
- a normalization fit over the whole sample
- the symbols that happened to survive
- the news outcome the model had already seen in training
That is look-ahead bias — the invisible killer of AI-built trading bots. The backtest wasn't a simulation of live trading. It was a replay of history with tomorrow's newspaper already sitting on the desk. Your account never got that newspaper. That's why the bot died.
Not because AI is useless. Not because all backtests are fake. Not because you should never use AI to code. Because trading code has one sacred rule:
At the moment of decision, the bot may only know what would have been known at that moment.
AI is very good at writing plausible code. It is not naturally good at respecting time. That gap is where the money dies.
Save this before your next beautiful AI backtest talks you into funding it. Send it to the friend who just messaged you a screenshot of a 90% win rate and the words "should I go live?" — Maybe. After the bot proves it isn't a time machine.
The classic leak: deciding and filling on the same candle, using a close that's only known after that candle is finished.
Look-ahead biasLLM backtests can be biased when the model was trained on events inside the tested period — the future hidden in its weights.
Glasserman & Lin, arXiv ↗Modern AI-trading repos now ship look-ahead sentinel tests and lookahead-banned operators as real engineering guardrails.
Vibe-Trading (HKUDS) ↗The one-sentence version
A backtest can accidentally use information from the future. Live trading can't — the future hasn't happened yet. That sounds obvious. It is not obvious to code, especially code written by AI, which writes things that look correct: they compile, they run, they backtest beautifully. But in trading, "correct" means something stricter:
- causal — uses only what was knowable then
- point-in-time — no peeking past the decision
- closed-bar only — never the candle still forming
- cost-aware — spread, commission, slippage
- no repaint — closed signals stay frozen
- no future statistics — nothing fit on the whole sample
If your bot enters on the current candle's close but that candle is still forming live, the backtest is cheating. If your indicator rewrites old signals as new bars arrive, it's cheating. If your normalization touches the full dataset, it's cheating. If your symbol universe only includes assets that survived, it's cheating. And if your LLM sentiment model was trained on the future of the test period, it may be cheating in a way that looks exactly like intelligence.
The fix isn't use a better AI. The fix is to force causality into the prompt, then audit the code.
Your backtest could see the future. Your account can't.
| What you believe | What is actually happening |
|---|---|
| "The backtest proves the code works." | It proves the code worked inside the tester's rules — and those rules may allow future data. |
| "AI wrote correct trading code." | AI wrote plausible code. Trading requires causal code. |
| "78% win rate is the edge." | It may be 78% on the bars where the bot already knew the answer. |
| "It failed because the market changed." | It may have failed because live trading removed the future input it leaned on. |
| "The equity curve is clean." | A curve that's too clean is often the smell of leakage, not the proof of edge. |
| "I'll just re-optimize it." | Re-optimizing a time machine gives you a prettier time machine. The leak is structural. |
I — The tell: a backtest too clean to be true
Start with the smell, because the smell is free. Look-ahead bias rarely looks like a bug — it looks like success. The equity curve is smooth, the drawdown is tiny, the losses are polite, the win rate is suspiciously high, and the strategy never seems to get trapped in the ugly stretch where real systems start to sweat. You feel proud. You should feel curious.
Real edges are not usually that clean. They're lumpy, noisy, and embarrassing in places. A real system can make money and still have weeks where it looks like it was assembled during a power outage — that's normal. A first-draft AI bot with a flawless curve should be treated like a stranger offering free diamonds in a parking lot: maybe it's real, but check the receipt first. The beauty is the warning, not the trophy — and AI has no shame about accidentally building a time machine.
II — Sin #1: same-bar entry
This is the classic, and it catches almost everyone. Your rule says enter when the candle closes above the band. In real life you only learn that the candle closed above the band after it closes — and the earliest you could actually act is the next candle's open. But a naive backtest decides on that bar and fills you at the very same bar's close: a price you could only know once the decision was already in the past. The bot bought the answer after reading the answer key.
The code usually looks innocent. In many platforms, index 0 is the current, still-forming bar:
// THE SIN — decides using the current, still-forming bar
if (Close[0] > UpperBand[0])
Buy(); // filled on a close you can't know in time
The honest version shifts everything back by one finished bar:
// THE FIX — decide on the last CLOSED bar, fill at the next open
if (Close[1] > UpperBand[1])
BuyAtNextBarOpen();
One index is the whole difference between a tradable signal and a historical magic trick. Same-bar errors are especially deadly because they often capture exactly the tiny slice that made the system "profitable" — the move from signal close to next open, the spread, the slippage, the small delay real life charges and a lazy backtest forgets. Strip it out and the edge frequently goes with it. Probably an accident. Still expensive.
III — Sin #2: repainting indicators
Some indicators quietly rewrite their own history. A buy arrow lands exactly on the bottom, a pivot looks obvious, a trend flip looks clean — but only because the calculation peeks at bars that printed after the point it's drawn on. On the historical chart it looks clairvoyant. Live, the signal shifts, disappears, or changes as new candles arrive, and the perfect entries you backtested never existed at the moment you'd have needed them.
AI hands you these because the most-copied versions online are themselves built with future-referencing windows — it learned from a swamp and sometimes brings swamp water into your EA. If a past signal can still move, you can't trade it — you can only admire it after the fact. The audit question is simple: once a bar closes, does that bar's indicator value stay frozen forever? If not, the backtest is showing you a chart that live trading never had.
IV — Sin #3: leakage in the math
This one hides inside the "smart" parts — normalization, z-scores, min-max scaling, feature engineering, model training, sentiment scoring. Anything that touches the whole dataset can leak the future. Normalize RSI using the mean and standard deviation of the entire backtest period and it sounds harmless, but now every historical bar's value carries a faint fingerprint of bars that came later. Train a model on all the data and then "backtest" inside that same period and you're not testing — you're grading a student with the answer sheet open.
The AI version is stranger still. If you use a language model to score historical news sentiment, the model may have been trained on text from after each event — it can already "know," in its weights, how the story turned out. Researchers have measured exactly this in GPT-driven sentiment predictions, and newer work names it directly as parametric look-ahead bias in LLM backtesting. The model doesn't need a future column in the spreadsheet; it can carry tomorrow's knowledge in its weights. The rule is unforgiving: every statistic must be fit on past data only, then applied forward — no full-sample scaling, no overlapping train/test, no "it's probably fine." The market charges for probably.
V — Sin #4: survivorship and symbol selection
Sometimes the leak isn't in a line of code — it's in the universe you pointed the code at. You test on the coins or stocks that exist and matter today, but the ones that died, delisted, or collapsed to dust are gone from the data. Now the strategy looks great because every asset in the sample survived long enough to sit the exam. "Buy the dip" is heroic when every name eventually recovered — because the names that didn't recover were quietly removed from the room.
If your test only contains the survivors, you've pre-selected the future and called it research. The fix is unglamorous: test on the universe as it existed at each point in time, delistings and blowups included.
VI — Sin #5: the bugs that only fire live
Not every failure is foresight. Some are plain bugs the Strategy Tester is too polite to punish:
- off-by-one bar indexing, or reading array position
0when you meant the last closed value - indicator buffers used before they're ready
- a division with no zero-guard that never trips on clean history, then throws on the first chaotic morning
- orders filled at the exact high or low — a price no real broker would give you
- no spread, no commission, no slippage, so a strategy that scalps tiny moves "works" in a frictionless world that doesn't exist
- broker minimum-lot and stop-level rules, session and time-zone mismatches, news gaps — all ignored
General-purpose models are notorious for shipping code that backtests fine and then misbehaves only at runtime. The tester forgives impossible fills and free trades; your broker forgives nothing. Always re-run with spread, commission, a tick of slippage, and next-bar execution. If a strategy only works for free, it doesn't work — it works in a simulator with no rent.
VII — Why AI does this specifically
None of this means the model is dumb. It means it's optimizing for the wrong target. An LLM writes code that's plausible — code that resembles its training examples and runs without erroring. It does not naturally hold the one mental model trading code needs most: what was knowable at the exact moment of decision? That's causality, and a next-token predictor doesn't track it unless you force it to. So it reaches for the patterns that fill tutorials and make a backtest look better:
Close[0]of the forming bar, because examples use it- full-array normalization, because that's the clean-looking way
- indicators that repaint, because the popular versions do
- today's symbol universe, because that's the data in front of it
- same-bar fills with no costs, because the tester allows it
| What AI optimizes for | What live trading needs |
|---|---|
| compiles | causal (only past data) |
| resembles the tutorials | point-in-time |
| backtest looks good | survives a one-bar delay |
| clean, confident code | realistic costs |
| a plausible answer | a tradable assumption |
A model is graded on plausibility; your account is graded on causality. Don't confuse the two games.
VIII — The fix: make it prove causality, then verify
You don't fix this by trusting a better model. You fix it by changing the contract. Don't ask "write me an EA for this strategy." Ask for a causal, point-in-time strategy that proves every decision uses only information available before that decision — and make the model show its work: which bar each line reads, when fills happen, how costs are modeled, whether any indicator repaints. Forcing it to account for its own data access surfaces most leaks before you ever hit run.
Then verify, because a contract you don't check is just a wish. Two tests catch the large majority of look-ahead. The first is the shift test: delay every signal by one full bar and re-run. Delay every signal by one bar — a real edge only dents, but a time machine collapses. The second is a cost-loaded walk-forward: train or tune on earlier data only, freeze it, then test once on later data — no rescue tweaks, no peeking twice, no turning the holdout into in-sample with better branding. The goal isn't to prove the bot will win. The goal is to prove the backtest was at least playing by time.
The causality prompt
Use this before you let AI write a single line of trading code. It does two unusual things: it forbids future data explicitly, and it forces the model to account for its own data access — which is where most leaks confess themselves.
You are writing trading strategy code. Hard rules, no exceptions:
1. CAUSALITY
A decision on bar N may use only information available at or before the
close of bar N-1. Never use the current forming bar's close, high, low,
or indicator value to decide an entry on that same bar.
2. EXECUTION
Signals are computed only on the last fully closed bar. Fills happen at
the next bar's open, or under an explicitly modeled realistic rule.
Never fill at the signal bar's close if that close triggered the signal.
3. NO REPAINT
Any indicator used for a signal must have fixed values once a bar closes.
If it can revise past values, store the value available at the time.
4. NO LEAKAGE
Any normalization, mean, std, z-score, ranking, scaling, model training,
or feature must be fit on past data only and applied forward. No statistic
may use future bars or the full dataset.
5. COSTS
Include spread, commission, and slippage. If unknown, expose them as
inputs and default to conservative non-zero values.
6. UNIVERSE
If testing multiple symbols, avoid survivorship bias. Do not select the
test universe using information from the end of the test period.
7. ACCOUNTABILITY
After the code, list every line that reads price/indicator/feature data.
For each: which bar index it reads, whether that data was knowable at the
decision time, and why it is not look-ahead.
8. TEST
Include a shift test: delay all signals one bar, re-run, and report
whether the edge survives.
Don't just ask for code. Ask for accountability. The model will still make mistakes — but now it has to expose the places those mistakes live.
The 20-minute audit
You don't need to be a quant. You need twenty minutes and the willingness to be disappointed early instead of expensively. Run this on any bot before you trust it.
Minutes 0–5 — Find the decision line
Open the entry logic and read the one line that fires the trade. Scan for anything that reads the current, still-forming bar:
Close[0] High[0] Low[0] "current bar" bar 0
Then ask: at the moment this trade fires, was this data actually known? If the answer is no, you found the time machine.
Minutes 5–10 — Run the shift test
Delay every signal by one full bar and re-run. Read the curve: a small dent means maybe real; a collapse means almost certainly a leak; an improvement means investigate your execution assumptions. It isn't perfect, but it's fast, and it catches a lot of fake edges before they reach real money.
Minutes 10–15 — Charge real costs
Add spread, commission, a tick of slippage, next-bar execution, and your broker's minimum stop distance. Re-run. If the strategy only worked while trading was free, it doesn't work — it was a cost illusion.
Minutes 15–20 — Check repaint and leakage
Step through the chart bar by bar and ask: do closed signals stay fixed, or do old arrows move? Do historical indicator values change as new bars arrive? Is every statistic fit on prior data only? Was the model trained on data overlapping the test? Was the symbol universe known at that time? You're not proving perfection — you're finding the obvious leaks before they get expensive.
Where this meets ProEA
Here's our stake in this, said straight. MTR was not vibe-coded by a chatbot. It's human-written MT5 source — 21 files, 16,923 lines — and you can read every one of them. That matters because look-ahead bias cannot be audited from a screenshot. You can't inspect a black-box equity curve; you can't verify a compiled EA that refuses to show its entry logic; you can't check whether it uses the forming candle if you can't read the code. With source, you can open the logic, find the entry line, check the bar index, see whether signals lean on closed candles, look for repaint, and read what costs the backtest actually charged. You cannot audit a black box, and you cannot audit a bot you can't read — but you can audit source.
That doesn't make MTR safe and it doesn't guarantee profit. MTR can lose. Any system can lose. But readable source changes the relationship: instead of "trust this curve," the standard becomes "here is the code, here are the assumptions, try to break them." The product isn't a promise of profit — it's a thing you're allowed to verify. And that's exactly what an AI-built black box tends to deny you: not always out of malice, but because the code was produced fast, looked good, backtested well, and nobody ever asked the one question that matters — what did this bot know at the moment it decided?
Disclosure
We sell source and evidence you can inspect — not outcomes, not guarantees. AI-generated trading code can carry look-ahead bias, repainting logic, unrealistic execution, survivorship bias, missing costs, and live-only bugs. Human-written code can carry them too. A clean backtest does not prove a system is tradable, and even a shifted, cost-loaded, point-in-time backtest is still not a guarantee. Trading is risky; leverage magnifies the risk; past performance is not future performance. MTR can lose. Any system can lose. The point is not to claim certainty — it's to make the code auditable enough that hidden future data has fewer places to hide.
The one question for any AI trading seller
Before you pay for any AI bot, ask one thing and watch the reaction:
Show me the entry line. Prove it doesn't use the current bar's close. Then show me the same backtest with a one-bar signal delay and full costs.
An honest seller can answer in minutes; a serious builder respects the question. Anyone who refuses may be selling you a time machine and hoping you only find the exit after you've gone live.
Your first 20 minutes
Don't take our word for any of it. Take any bot you already own — AI-written, bought, or copied from a forum — open the entry logic, find the bar it reads, delay the signal one bar, charge real costs, and check for repaint. Then do the same with anything you're considering, ours included. Verify us. Don't trust us. Source isn't perfect; it just gives you the right to inspect the thing before it touches your money. That right is the whole point.
One last thing
Your backtest didn't lie to you. It just lived in a world where tomorrow was visible — and you don't live there. Your account doesn't. Your broker definitely doesn't. The AI didn't write you a strategy; it may have written you a time machine, and the only exit is live trading: real spread, real slippage, real delay, real uncertainty, and the future switched off. Read the code before you fund the ride.



