Start with an idea
Describe the entry, exit, risk, and market rules. The GPT creates a compatible Pine Script v6 strategy and runs the first backtest.
Pine Script backtesting inside ChatGPT
Describe a strategy in plain English or paste Pine Script v6. PineScript API generates or validates the code, runs a close-only OHLC backtest, and returns the exact script, resolved settings, dataset coverage, risk metrics, and trades.
A Pine Script backtesting GPT powered by a dedicated execution API
Test a 20/50 SMA crossover on BTCUSD from 2021–2024.
1 //@version=6
2 strategy("SMA 20/50 Crossover", overlay=true)
3
4 fast = ta.sma(close, 20)
5 slow = ta.sma(close, 50)
6 long = ta.crossover(fast, slow)Illustrative result for interface demonstration.
Two ways to begin
Describe the entry, exit, risk, and market rules. The GPT creates a compatible Pine Script v6 strategy and runs the first backtest.
Paste Pine Script v6. The GPT preserves the original logic, checks known compatibility surfaces, and does not silently replace unsupported behavior.
Reliability first
A high return means little if the strategy used information that was unavailable at the time. The public environment is designed to reduce common repainting and lookahead paths.
Evaluate strategy logic once per completed chart-timeframe bar using the public close-only OHLC execution model.
Live tick recalculation and immediate strategy recalculation after simulated fills are disabled in public mode.
Multi-timeframe and cross-symbol requests are rejected because their timing, alignment, and coverage are outside the current parity contract.
Each run records the exact script, resolved settings, engine build, dataset ID, loaded coverage, trade window, and request fingerprints.
IMPORTANT A later rerun may differ if the underlying dataset or engine build has changed. The receipt identifies the environment used for the original result. Read the execution model →
How it works
Start in natural language or bring your existing script. PineScript API keeps the strategy, test, and revision loop in one GPT conversation.
Start from natural language or provide a Pine Script v6 strategy() script whose original logic should be preserved.
Resolve the exact dataset, timeframe, trade window, capital, costs, and Pine input overrides before execution.
DATA / SETTINGSThe GPT inspects known surfaces first. The engine performs the authoritative compile, runtime, setting, and broker-state checks.
SUBMIT / EXECUTEAsk follow-up questions about risk and trades, or compare up to 30 input variants without leaving the conversation.
ANALYZE / OPTIMIZECapabilities
Purpose-built around the moments that usually interrupt momentum: translating rules, running a test, reading the numbers, and revising the idea.
Signals are evaluated from confirmed chart-timeframe bars rather than live intrabar tick changes.
Model trading costs as part of the run instead of evaluating an unrealistically frictionless strategy.
Test market, limit, and stop entries with simple stop-loss, take-profit, and full-position exits.
Override Pine inputs while preserving the script and settings used to create each result.
Learn the workflow
Use focused documentation to check compatibility, understand execution assumptions, and start from a strategy example you can inspect line by line.
See how GPT actions turn a strategy and test configuration into a documented backtest.
Read guide →COMPATIBILITYCheck supported, constrained, and rejected language and broker-state surfaces.
Read guide →RELIABILITYUnderstand close-only calculations and why cross-context requests are restricted in public mode.
Read guide →EXECUTION MODELSeparate completed-bar calculations from market, stop, and limit order fill behavior.
Read guide →DATAReview the dated public catalog snapshot, resolution rules, coverage, and refresh states.
Read guide →OPTIMIZATIONRank up to 30 input variants by return, Profit Factor, or drawdown-aware objectives.
Read guide →VERIFICATIONUse the same code and settings to investigate differences between two backtest environments.
Read guide →EXAMPLEStart with a transparent Pine Script v6 trend-following example and a review checklist.
Read guide →EXAMPLETest a simple single-position RSI strategy without multi-timeframe dependencies.
Read guide →DOCUMENTATIONStart from plain language or existing code, configure a run, and inspect resolved settings.
Read guide →Review the run
Evaluate return, risk, sample size, long and short behavior, and the trades that produced the summary.
Analyze and optimize
Ask follow-up questions about one completed run, or test up to 30 input configurations in a single optimization request.
Review monthly and yearly returns, long-versus-short behavior, the maximum-drawdown period, trade statistics, and selected best, worst, or recent trades.
Rank completed variants by Profit Factor, Net PnL %, Net PnL minus drawdown, or return over drawdown. Each submitted variant counts as one backtest run.
Read the optimization guide →VALIDATE SEPARATELY Optimization only finds the best result among the tested variants. It does not prove that the selected settings will remain profitable. Validate selected settings on a separate period.
Built for the loop
For Pine developers, systematic traders, and strategy researchers who want less context switching between an idea and its first useful test.
Start a backtest in ChatGPT ↗Compatibility
The public engine is not a complete implementation of every TradingView Pine language, visual, data-request, and broker-emulation feature.
pyramiding = 0strategy.close and close_allclose_entries_rule="ANY"strategy.order used like an entry while flatrequest.security() and multi-timeframe dataUnsupported code is not silently transformed into a different strategy. If compatibility would change the original logic, execution stops and the relevant limitation is identified.
Audit the result
Review the exact script, resolved settings, dataset ID and loaded coverage, trade window, engine build, and request fingerprints behind the result.
Run a documented backtest ↗Receipt field preview — not a live run record.
FAQ
Yes. Open the PineScript API GPT, describe or paste your strategy, and use the conversation to run and refine the backtest workflow.
ChatGPT Plus or higher is required. For the best Pine Script generation, debugging, and backtest interpretation, use the newest model available because newer models generally provide stronger reasoning.
You can begin with a plain-language strategy description. If the script matters to a real decision, review the generated rules and code carefully before relying on the output.
No environment can guarantee zero differences in every case. Live tick recalculation and cross-context data requests are restricted, but exchange data, historical revisions, sessions, dataset coverage, fill assumptions, and overfitting can still affect results.
Availability follows the managed public dataset catalog, not every TradingView symbol. The current catalog includes selected crypto, gold, and US-equity datasets. Check the dated data availability guide or ask the GPT to resolve the exact dataset before running.
Strategy calculation and order filling are separate. New market orders fill at the next available simulated price by default. Pending stop or limit orders may fill inside a bar under OHLC broker-emulation rules. On-close processing, when enabled, is recorded with the result.
The date range controls when new entries are allowed; it does not truncate indicator history. Earlier bars may load for warm-up, and an open position may be force-closed immediately after the trade window ends.
Yes. ChatGPT Plus or higher is required to use the GPT, and the first backtest may ask you to connect your PineScript API account. PineScript API trial credit can permit a run without a separate active API subscription.
One backtest consumes one run. In an optimization request, each submitted input variant consumes one run. Up to 30 variants can be submitted, subject to available run credits.
No. Live results may differ because of spreads, liquidity, latency, market impact, funding costs, execution rules, and data differences.
No. PineScript API is for strategy research and software validation. Backtest results are simulations, not guarantees of future performance.
Test with context
Review the data, execution settings, risk, and trade history behind the return—not the headline number alone.
Open PineScript API ↗