PineScript backtests offline चलाएँ, अपने data पर
PineForge PineScript v6 को native C++ में transpile करता है और Docker के via आपकी local machine पर चलाता है। Local-first, byte-reproducible, हर जगह जहाँ Docker चलता है वहाँ चलता है। अपना OHLCV CSV लाइए।
Offline क्यों?
Browser-based backtesting chart-side iteration के लिए बढ़िया है। Offline backtesting वो है जो तब चाहिए जब अगला step strategy के पीछे पैसा लगाना हो: जब audit trail चाहिए, जब CI को हर commit gate करना हो, जब दो महीने पुराने result को आज bit-for-bit reproduce करना हो।
Offline backtests चलाने से वो चीज़ें मिलती हैं जो browser-based testers नहीं दे सकते: results होते हैं byte-reproducible — same input, same output, हर बार। आप engine version pin करते हैं, results repository में check-in करते हैं, commits के बीच trade lists diff करते हैं, और पूरी चीज़ अपनी CI pipeline में headlessly चलाते हैं। जो CSV आप feed करते हैं वो आपका है; जो binary चलता है वो local है; जो report वापस मिलती है वो auditable है।
Practical list क्या unlock होता है: version-pinned engines ताकि दो महीने पुराना commit आज वही trade list produce करे; custom data ingestion ताकि अपने exchange के tick reconstructions, अपने data vendor के point-in-time equity prices, या किसी भी alt-data feed पर test हो जिसे OHLCV में serialize किया जा सके; CI integration ताकि regressions production तक पहुँचने से पहले build fail कर दें; और multi-broker portability क्योंकि strategy की logic platform से locked नहीं — वो एक file है।
अगर कभी आपको colleague के साथ backtest result share करना पड़ा हो और एहसास हुआ हो कि उसे ‘share’ करने का इकलौता तरीक़ा chart का screenshot है — वही चीज़ offline running आपको देती है।
कैसे काम करता है
तीन steps। Pine source से JSON trade report तक का full workflow पहली बार दो minutes से कम लगता है और हर बाद के run में तीस seconds से कम।
Step 1 — Runtime pull कीजिए। एक ही container image। न pip, न key, न signup — transpile और backtest दोनों उसी के अंदर offline चलते हैं। Personal trading के लिए free।
Step 2 — अपनी Pine को C++ में transpile कीजिए। Container को transpile-only mode में चलाइए और वो आपकी PineScript v6 को locally एक पूरी C++ source file में बदल देता है। Runtime पर कोई Pine interpreter नहीं चलता — engine उसे native machine code में compile कर देता है।
docker run --rm --network=none \ -e PINEFORGE_TRANSPILE_ONLY=1 \ -v "$(pwd)/my_strategy.pine":/in/strategy.pine:ro \ ghcr.io/pineforge-4pass/pineforge-engine:latest > strategy.cpp
Step 3 — Backtest। अपनी OHLCV CSV को generated C++ के साथ mount कीजिए और container चलाइए। Engine data file पढ़ता है, strategy को bar-by-bar execute करता है, और stdout पर JSON report लिख देता है।
docker run --rm --network=none \ -v "$(pwd)/strategy.cpp":/in/strategy.cpp:ro \ -v "$(pwd)/ohlcv.csv":/in/ohlcv.csv:ro \ ghcr.io/pineforge-4pass/pineforge-engine:latest > report.json
JSON output में entry/exit prices, bar indices, position sizes के साथ full trade list, और net PnL, max drawdown, total trades, profit factor, Sharpe ratio का summary block होता है। Same major version के patch releases पर सारे fields stable हैं — scripts में parse करना safe है।
बस यही पूरा workflow है। न GUI, न account re-authentication, न chart loading। अगर Docker चला सकते हैं, तो PineForge offline backtests चला सकते हैं।
क्या-क्या backtest कर सकते हैं
छोटा जवाब: कुछ भी जिसे OHLCV में serialize कर सकते हैं। PineForge किसी market data provider से connected नहीं। आप data लाते हैं; engine strategy चलाता है।
अपने exchange से crypto. Binance, Bybit, Kraken, या किसी भी REST/WebSocket API वाले exchange से raw trade data pull करें। जो भी timeframe आपकी strategy use करती है उस पर aggregate करें। CSV directly feed करें। ठीक उसी pair-and-venue पर test करें जिस पर trade करेंगे।
अपने data vendor से equities. Polygon, Norgate, BarChart, Tiingo — अपना source चुनिए, point-in-time adjusted prices export कीजिए, अपने actual fills और survivorship-bias-free universe पर backtest चलाइए।
Tick reconstructions. अगर Level 2 data है और ticks से reconstruct किए synthetic 1-second bars पर test करना चाहते हैं, तो कर सकते हैं। Tick data से OHLCV generate कीजिए और pass कर दीजिए। Engine को नहीं पता और न परवाह कि bars कहाँ से आए।
Alt-data. Sentiment scores, on-chain metrics, funding rates, options skew — अगर इसे bar index से aligned time series की तरह express कर सकते हैं, तो Pine में custom data columns के via incorporate कर सकते हैं और offline test कर सकते हैं।
Gallery में 246-strategy reference suite को TradingView CSV exports (parity validation के लिए) और custom CSV datasets (regression testing के लिए) पर backtest किया गया। 246 में से 245 canonical strict-excellent tier पर hit करती हैं (PnL drift ≤ 0.5% comparison window पर)। बाक़ी 1 एक documented TV-side anomaly है — deep-analyzed, TradingView state तक trace। Zero real engine bugs बचे हैं।