lookahead-guard

Detect lookahead bias in trading indicator and strategy code.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/lgbarn/quantdev --skill lookahead-guard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lookahead-guard
Source: https://github.com/lgbarn/quantdev/tree/main/skills/lookahead-guard
Command: npx skills add https://github.com/lgbarn/quantdev --skill lookahead-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents the most common and devastating bug in trading systems: lookahead bias, which occurs when code accesses data that wouldn't be available at the time a decision is made.

Core Features & Use Cases

  • Detects Future Data Access: Identifies instances where code uses future bar information or unconfirmed current bar data.
  • Cross-Platform Guidance: Provides specific rules and dangerous/safe patterns for Pine Script, NinjaScript, Go, and Python.
  • Use Case: Ensure your trading indicator's calculation correctly uses only data from completed bars, preventing backtest results from being artificially inflated by phantom profits.

Quick Start

Review the attached indicator code for any instances of using the current bar's close price before it is confirmed.

Frequently Asked Questions about lookahead-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is lookahead bias in trading code and how does it affect backtesting?

Lookahead bias in trading code occurs when your strategy accesses future bar information or unconfirmed current bar data during signal generation, causing backtesting results to be artificially inflated by phantom profits.

How do I detect lookahead bias in my trading indicator code?

You detect lookahead bias by reviewing indicator code to identify future data access, close-price peeking during bar formation, and improper array indexing that uses future bar information instead of data from completed bars and the current tick.

Does this lookahead bias detection work with Pine Script and NinjaScript?

Yes, it provides cross-platform guidance with specific dangerous and safe code patterns for Pine Script, NinjaScript, Go, and Python to ensure your trading strategy correctly uses data from completed bars.

What's the best way to prevent future data access in backtesting strategies?

The best way to prevent future data access in backtesting strategies is to enforce the core principle that only data from completed bars and the current tick is permissible at any decision point during indicator development.

Why do my backtest results show artificial profits during bar formation?

Your backtest results show artificial profits due to lookahead bias from close-price peeking during bar formation, where your code accesses unconfirmed current bar data before the trading decision is actually made.