Most of us can now build a working trading bot in an afternoon. What almost none of the tutorials give you is a way to answer the only question that matters: **does this strategy make money, or does it just run without crashing?**
Those are different questions. Joseph made this split really clearly in his posts here — strategy evidence and operational readiness are independent, and a bot that never errors while trading a worthless strategy is a very efficient way to lose money. I want to show the missing half: how to get strategy evidence cheaply, in minutes, before anything touches an exchange.
I'll use a real worked example, including the part where I found a bug in my own test.
### The trap that started this
I deployed a bot on a 4-hour schedule and planned to paper trade for 72 hours to "see how it does." Then I did the arithmetic:
- 72 hours ÷ 4-hour cron = **18 evaluations**
- Historically, only **0.9%** of evaluations on that timeframe produced a trade
- Expected trades in 72 hours: **0.16**
I was going to wait three days to collect approximately zero trades, and then probably deploy anyway. Forward testing at low frequency is almost useless for judging a strategy. A backtest produced **2,581 trades in three minutes**.
### The one rule that makes a backtest mean anything
**The backtest must run the exact same code the bot runs.**
If you reimplement the strategy in your backtest, you are validating code that never trades, and trading code that was never validated. They drift, silently.
The fix is simple: extract the decision logic into a shared module both import.
```
strategy.js <- indicators + entry/exit decisions, pure functions
|
+-- bot.js (live/paper: prints, places orders)
+-- backtest.js (replays history)
My backtest asserts indicator parity on every run and **refuses to print results** if the numbers diverge from what the live bot computes. That assertion is worth more than any statistic in the output.
## Bias controls you need or the numbers lie
- **No look-ahead.** A signal on bar *i* fills at bar *i+1*'s open. You cannot know a bar's close before it closes.
- **Real costs.** Fees both sides plus slippage. For crypto spot: 0.1% fee + ~0.05% slippage per side = **0.30% round trip**.
- **Cache your data.** Pull once, save to disk, so every run is reproducible.
- **Test parameter sensitivity.** If the result only survives at one exact threshold, it's an overfit, not an edge.
### Worked example: a popular tutorial strategy
VWAP + EMA(8) + RSI(3), the "all three conditions must align" type. Tested on BTCUSDT across 15m/1h/4h, spot and futures, 1–2 years:
| Timeframe | Mode | Trades | Win rate | Expectancy/$100 | Profit factor |
|---|---|---|---|---|---|
| 15m | spot | 571 | 8.8% | -$0.30 | 0.05 |
| 1h | futures | 652 | 21.6% | -$0.29 | 0.20 |
| 4h | spot | 39 | 30.8% | -$0.28 | 0.50 |
Profit factor needs to exceed 1.0. Best result was 0.50 — losing twice what it wins.
**Then the diagnostic that actually explains it.** Notice expectancy is ≈ -$0.30 in *every* row, which is exactly the round-trip cost. So I re-ran with fees and slippage set to zero to isolate the raw signal:
**Gross edge: +0.006% per trade. Round-trip cost: 0.30% per trade.**
The costs were **50× larger than the signal**. That's not a tuning problem. I swept 48 parameter combinations — every single one lost money; the best still bled -$0.23 per $100. Loosening the entry filter just bought more of the same negative-expectancy trade.
### The part that would have fooled me
With costs removed, that strategy wins **65% of the time**.
Tiny wins from the RSI-crosses-50 exit, larger losses from the hard stop. Net zero before costs, steady bleed after.
Here's why that's dangerous rather than merely useless: if my 72-hour paper run had produced 2 trades and both won — about a 42% chance at a 65% win rate — I'd have concluded "it works" and gone live. **Win rate without expectancy and sample size tells you nothing.**
## Then I tested a serious strategy, and found a bug in my own backtest
I ran Carver-style EWMAC trend following (volatility-scaled positions, multiple speeds) on a diversified ETF basket. First results came back with max drawdowns of **109%, 128%, 133%**.
Those are impossible. A drawdown over 100% means equity went negative. The cause: targeting 20% volatility on a ~5%-volatility bond ETF implies 4x leverage, which my position sizing happily produced and my accounting allowed — but a cash account cannot borrow.
I mention this because it's the real lesson: **a backtest that produces an impossible number is doing you a favour.** The dangerous backtests are the ones that return plausible-looking results while quietly assuming something false. Sanity-check every output against physical reality before you believe any of it.
After adding a leverage cap, results became sane — and interesting:
| Portfolio (9 ETFs, 18.5 yrs, unleveraged) | Sharpe | CAGR | Vol | Max DD |
|---|---|---|---|---|
| Long/short | 0.06 | 0.2% | 5.3% | 13.4% |
| Long-only | 0.33 | 1.2% | 3.8% | 7.5% |
| Buy & hold SPY (benchmark) | 0.55 | 8.9% | — | 56.5% |
Diversification genuinely worked — portfolio volatility dropped to 3.8% from ~10% per instrument. That's the free lunch doing its job. But unleveraged, low volatility means low return, and plain buy-and-hold beat it on return while the trend system beat it enormously on drawdown (7.5% vs 56.5%).
Which is a real conclusion, just not the exciting one: **for a small unleveraged account, this class of system is buying drawdown insurance, not extra return.**
### What I'd suggest
1. Build the shared-module structure first, before you deploy anything.
2. Set a written bar *before* you look at results — mine: profit factor > 1.3, positive expectancy after real costs, 200+ trades, holds on data you didn't tune on, survives ±20% parameter changes.
3. Backtest first, deploy second. Most tutorials do this in the opposite order, which is how people find out with real money.
4. Sanity-check outputs against physics. Drawdown > 100%, Sharpe > 3, win rate > 80% — assume a bug until proven otherwise.
Happy to share the harness if it's useful to anyone. It's ~200 lines of JS and it answered in three minutes a question I was planning to spend three days not answering.
### Correction
The ETF table in my post used Yahoo's plain close, which ignores dividends, so it understated every fund and the SPY benchmark. Corrected, dividend-adjusted numbers (9 ETFs, 18.6 yrs, unleveraged): trend long-only Sharpe 0.52 / CAGR 2.0% / max DD 6.1%; long/short 0.19 / 0.9% / 12.1%; SPY buy-and-hold 0.64 / 10.8% / 55.2%. The conclusion is unchanged — buy-and-hold wins on return, the trend system wins on drawdown — but the multiples I quoted were off. Details in the README's correction log.