DEV Community

Cover image for Your Trading Bot Can't Tell a Fake Candle From a Real One
PineGen AI
PineGen AI

Posted on

Your Trading Bot Can't Tell a Fake Candle From a Real One

The futures market was closed, so why is there a candle on this chart?

In late May, bad data from a provider put fake Saturday candles on intraday charts for ES, NQ and the Micros (ESM26, MNQM26, ESZ26). Daily charts and above were unaffected. It took a few days to clean up, real-time updates dropped on some contracts along the way, and it was fully fixed by June 4th.

🔗 https://youtube.com/shorts/-XRudNuZbDY

Why this matters for automated strategies

A person looking at a Saturday candle thinks "that's odd." A strategy just sees a bar. If its logic only asks "did my condition fire?", a phantom bar can produce a phantom signal.

The fix: a session filter

A strategy should only act during real trading hours. It's a guard many traders never add, and it's the step you forget until it costs you.

//@version=6
strategy("Session-filtered example", overlay=true)

// Block anything stamped on a Saturday (exchange closed)
isSaturday = dayofweek(time, "America/New_York") == dayofweek.saturday

// Your real entry condition goes here
longCondition = ta.crossover(ta.sma(close, 10), ta.sma(close, 30))

if longCondition and not isSaturday
    strategy.entry("Long", strategy.long)
Enter fullscreen mode Exit fullscreen mode

Extend it to block the Sunday pre-open and the daily maintenance break for the contract being traded. Then run a backtest and scan the trade list for any weekend timestamps.

Tooling that can help

AI-assisted tools like PineGen AI can generate this kind of filter from a plain-English prompt such as "Block all signals on weekends and outside Globex hours," validate the Pine Script v6 against the TradingView compiler, and show a backtest where a Saturday trade is easy to spot. [https://www.pinegen.ai/]

Do you filter weekend and off-hours bars in your strategies? Share your approach in the comments.

Educational content, not financial advice. Trading futures involves substantial risk of loss.

Top comments (0)