SShortSingh.
Back to feed

Pine Script lookahead bug makes backtests profitable but live trades lose money

0
·1 views

A documented Pine Script mechanic causes strategies to appear profitable in TradingView's Strategy Tester while losing money in live trading. The issue stems from using 'barmerge.lookahead_on' in the request.security() function, which inadvertently feeds future price data into historical bar calculations during backtesting. On live bars the problem is invisible, since no future data exists yet, but once those bars become historical they are recalculated with complete data, causing the chart to 'repaint' into a different signal history. This discrepancy means a paper-trading session can falsely confirm a strategy's validity until a chart reload reveals the backtest was built on information unavailable in real time. TradingView's own documentation explicitly warns against this setting, advising developers to verify it does not compromise logic by leaking future data into past bars.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Beginner Developer Builds Multi-Page HTML-Only Website to Master Web Fundamentals

A beginner web developer created a multi-page website using only HTML, with no CSS or JavaScript, as part of a self-directed learning series. The project includes sections such as Home, About Me, Skills, Projects, and Contact, all connected through HTML hyperlinks. Key concepts practiced include semantic HTML elements, image embedding with alt attributes, internal and external links, and metadata usage via the viewport meta tag. The exercise helped the developer understand how multiple HTML files work together to form a complete website structure. The developer plans to next learn CSS to improve the site's layout, typography, and responsive design.

0
ProgrammingDEV Community ·

Study of 300 websites finds no preferential treatment for signed AI agents

A developer built a custom tool and tested 300 public websites to verify two widely repeated claims: that sites treat cryptographically signed AI agents differently, and that some sites hide text visible only to AI models. Signed requests made no positive difference — in the three cases where signing had any effect, the signed agent was actually treated worse. Hidden machine-only text appeared on just one page out of 281, a single transparent span on firecrawl.dev directing AI agents to an onboarding file. The study also found that the median webpage costs an AI reader 2,592 tokens, while the seven sites serving markdown to machine clients cut that to around 962 tokens, though most of those markdown responses had caching header errors. A key methodological finding was that 27% of homepages returned different content between identical requests, meaning any signed-versus-unsigned comparison must account for natural page variation to avoid measuring noise.

0
ProgrammingDEV Community ·

How to Build an Offline-First React App Using TanStack Query and IndexedDB

Offline-first development reframes how frontend apps handle connectivity by treating the user's device as the primary source of truth rather than the network. Instead of showing error screens or loading spinners when a signal drops, the app responds instantly from locally cached data and syncs with the server in the background when connectivity returns. A practical implementation relies on four coordinated layers: a Service Worker to cache the app shell, IndexedDB to store API responses and pending write operations, cache-aware fetch utilities to handle network-or-cache decisions, and TanStack Query with persistence to manage in-memory state across page refreshes. When a user triggers a data request offline, the system cascades through up to four fallback levels before returning a cache miss, meaning users almost always see meaningful data. This architecture is especially relevant for real-world conditions like weak mobile signals or patchy urban connectivity, and is designed for production apps with authentication and role-based access rather than simple demos.

0
ProgrammingDEV Community ·

Hugging Face's open-source mini robot crosses $1M in sales despite free design

Hugging Face's small open-source bipedal robot, standing just 25 centimeters tall and equipped with 15 actuators plus sensors including LiDAR, camera, and WiFi, has surpassed one million dollars in sales. The robot's hardware designs and software stack are fully publicly available through the company's LeRobot ecosystem, yet buyers continue to purchase the finished product rather than build it themselves. The milestone challenges the common assumption that open-source hardware cannot generate meaningful revenue, since transparency appears to build consumer trust rather than undermine sales. Hugging Face's approach contrasts sharply with the billion-dollar funding rounds currently flowing into large humanoid robotics firms, offering a lower-barrier model for independent builders. Analysts caution, however, that crossing $1M is an early proof of concept rather than evidence of a scalable business, given the notoriously thin margins in hardware manufacturing.