Side project · running since Sep 2026

Crude oil bots that trade while I sleep.

A hand-drawn idea on a TradingView chart became a fleet of Python bots trading CL futures on prop-firm accounts, 24 hours a day, five days a week. Here is how they're built and how every rule earned its place.

CL · H1 swing → M30 engulf · 3R
2Strategies, one switch per bot
159Unit tests gate every deploy
4 yrsOf 1-minute data in every backtest
1Rule engine for bots & backtests
Architecture

One process per account. One rulebook.

Each account runs its own self-restarting Linux service. Live trading, backtests and reports call the same rule functions, so a backtest can't quietly disagree with the bots.

Every 25 s

Read the market

Pull 1-minute bars and build 5 to 60-minute candles. Only completed candles are ever used.

Candle close

Check the rules

Every skipped setup is logged as a near miss with the one filter that blocked it.

Before entry

Guard rails

Daily loss stop, trade caps, and a hedge guard: no account long while another is short.

Entry

Place & protect

Stop entry with brackets, re-pinned to exact prices after the fill. Unprotected for 60 s? Closed.

In trade

Manage

Break-even at 2R, add-on at +1R, loss cap auto-close, flat before the prop firm's daily close.

Always

Report

Telegram for wins, losses and safety events; a daily report and an hourly ledger.

Strategies

Two ways to read the chart.

Each strategy, step by step. Steps describe a short; a long is the exact mirror.

Strategy 2 · main

H1 Swing Engulf

The hourly chart picks the turn; the 30 or 15-minute chart keeps the stop small, so a 3R target is realistic.

  1. Hourly swing. Bearish: a red H1 candle closes right after a green one, and its own high is at or above the highs of the two hours before it. Bullish: a green H1 candle closes right after a red one, and its own low is at or below the lows of the two hours before it.
  2. Engulf inside that hour. On M30, else M15, a red body fully covers the previous green body of at least 5 ticks.
  3. Quality check. The engulf candle has at least 0.6× normal volume and a range of at least 0.9 ATR.
  4. Entry. One tick past the engulf candle, stop at its other end, capped at 130 ticks.
  5. Target. 3R.
  6. Late fallback. If price has already passed the entry, use the H1 engulf instead. If that has passed too, skip.
  7. At +1R. Add to the position, except on Express accounts.
  8. At +2R. The stop moves to the entry.
  9. Loss cap. An open loss of $900 closes everything.
  10. End of day. One losing trade ends the day, with 5 trades at most. Flat by 04:10 MYT.
Strategy 1 · original

VWAP Break

A 5-minute moving-average breakout near VWAP, plus a 10-minute chart that trades only when the bot is flat.

  1. Touch. Candle 1 touches the EMA 20 or SMA 50.
  2. Clear and break. Candle 2's whole range clears that line and breaks candle 1, while staying inside candle 1 on the stop side.
  3. Trend check. If candle 1 touched both lines, trade only with the trend.
  4. Size check. The setup must be under 40 ticks. Setups of 41 to 49 ticks are also allowed.
  5. Near VWAP. Candle 2 closes within 0.5 ATR, or 0.7 ATR when the stop is 30 ticks or more.
  6. Fallbacks. If VWAP fails, take a 1R scalp with a stop under 18 ticks, or a 1R trend trade at least 70 ticks from VWAP with a stop under 40 ticks.
  7. Entry. One tick past candle 2, stop at candle 1's far end.
  8. Target. 2R, or 2.5R when volatility expands.
  9. Cancel. The order goes if candle 3 touches the line, price hits the target first, or 12 candles pass.
  10. In the trade. Add to the position when price is 32 ticks from the target.
  11. End of day. Stop after a $432 loss. Flat by 04:10 MYT.
Research

Four years, not four weeks.

Strategy 1 looked brilliant on the three months it was tuned on. Re-run on Jan 2023 to Oct 2026, it lost in three of four years: textbook overfitting. That result is why most bots now run Strategy 2.

Backtest, after fees and slippage. Hypothetical results; past performance does not predict future results.
YearStrategy 1 · VWAPStrategy 2 · Swing
2023 · never used to pick settings−$17,861+$13,289
2024−$45,471+$31,987
2025−$37,454+$8,937
2026 · to 22 Oct+$37,436+$52,214
Total−$63,350+$106,427
Kept

What made the cut

Stop for the day after a loss. A 10-minute chart when flat. Candle 2 stays inside candle 1. Cancel if candle 3 returns to the line.

Rejected

What didn't

44 moving-average pairs, swing-structure filters, 4 to 15-minute charts alone, prior-day sweeps, tail candles, other targets, ES and NQ.

Process

How a rule gets in

Backtest on the shared engine → check each year and the prop-firm pass rate → code with tests → a deploy that rolls back on any failure.

Engineering

Built like production, because it is.

Test-gated deploys159 pytest tests on a fake broker. A failing test restores every file and restarts nothing.
State that survives restartsTrades used and the day's opening balance live on disk, so a restart never resets the daily stop.
Contract rollThe bots follow the broker's active futures month on their own.
Failures turned into guardsA daily stop that silently never fired, old laptop bots still trading, a leftover order that briefly hedged two accounts. Each became a guard and a test.
Secrets stay secretAPI keys live only on the server, entered through a hidden prompt.
ToolingPython, pandas, systemd, ProjectX REST, Databento, Telegram, Pine Script, and Claude Code as a pair engineer.

See every account live: balances, open P&L and today's trades →

Next

Want the whole story?

I'm happy to walk through the code, the research and the mistakes.