Compare TradingView strategy scripts with a repeatable test
There is no demonstrated best TradingView strategy script for every market and timeframe. Choose a candidate whose rules you can inspect, compare it under the same execution and cost assumptions as alternatives, then evaluate the frozen rules on unused data. This guide provides a test specification, not a ranking based on measured returns.
Review Strategy OptimizerKey Takeaways
- A high historical return is a result for particular data and settings, not proof of future profitability.
- Price, source-code visibility, and strategy quality are separate questions.
- Set the selection criteria and holdout dates before reviewing candidate results.
- TradingView strategy orders are simulated. Forward observation does not prove broker fill quality.
Choose a strategy you can evaluate
Start with built-in strategies or public scripts whose description specifies the market, timeframe, entries, exits and position sizing. Confirm that the script produces simulated orders and a strategy report; a buy/sell indicator alone is not a backtestable strategy. Keep the publication URL, author, version and a copy of every setting with your results.
- Open-source: the code is visible. Make a working copy to inspect or edit it, and respect its license when reusing it.
- Protected: the code is hidden, but the published script is free to use. Free access does not imply source access.
- Invite-only: the author controls access and the code is hidden. Ask for testable rules and settings; neither payment nor restricted access establishes performance.
- For any candidate, reject a comparison that cannot reproduce the advertised symbol, period, sizing and costs. Hidden code limits a code audit, but visible code still requires one.
Two simple candidates for a controlled comparison
The following are untested research specifications, not recommended trades. Their purpose is to make the selection process reproducible. Pick an exchange-qualified symbol and a daily standard-candle dataset before running either candidate. Use the same date ranges, capital, fixed share or contract quantity, session and costs. Allow one long position at a time, with no shorting or pyramiding.
- Trend candidate: calculate 20-bar and 50-bar exponential moving averages from closes. While flat, enter when the 20-bar EMA crosses above the 50-bar EMA. Exit when it crosses below. This tests a directional-persistence hypothesis; repeated crossings in a range are the failure case to inspect.
- Reversion candidate: calculate RSI over 14 bars. While flat, enter when RSI crosses back above 30. Exit at the first close where RSI is at least 50, or after 10 completed bars beginning with the entry-fill bar, whichever comes first. This tests recovery after weakness; continued declines are the failure case to inspect.
- For both, evaluate signals only at bar close and submit market orders for the next available tick. Use no intrabar stop or target in this initial comparison. Neither candidate has a protective stop, so record adverse excursions and overnight gaps rather than assuming losses are capped.
- Warm up the indicators before each measured interval. Start flat and accept entry signals only inside the interval. At the close of the first bar opening on or after its end, submit a market exit for the next available tick and allow no new entries. Include that boundary exit and its costs in the interval result.
Make the execution assumptions visible
TradingView uses a broker emulator. With default bar-close calculation, a market order created at a close normally fills at the next bar open on historical data. On-close processing and extra recalculation settings change that model. Use standard candles and save those settings with each test; changing them between candidates changes the experiment.
- Commission applies to entries and exits. Choose percentage, per-contract or per-order fees to match the intended venue, and use a per-side amount when appropriate.
- Slippage is expressed in ticks and applies to market and stop orders. Set it from an explicit execution assumption, then repeat with a higher-cost scenario. One or two ticks is not a universal estimate.
- Limit orders have a separate fill-verification setting. Bar Magnifier uses lower-timeframe data to refine historical fill simulation; it does not model a broker queue or guarantee execution.
- Audit requested data and signal timing separately. A confirmed chart bar does not automatically confirm a higher-timeframe value. Unconfirmed values can repaint; lookahead that exposes unavailable future values is a separate source of bias.
Reserve data before choosing the winner
Use a chronological development, validation and final holdout split. For example, with sufficient data you could reserve the earliest 60% for development, the next 20% for candidate selection and the final 20% for one final evaluation. These percentages illustrate a protocol, not a statistical minimum. Seasonal coverage, trade frequency and regime changes matter more than a convenient split.
- Before testing, write down the candidate rules, allowed parameter values, maximum acceptable drawdown and selection metric. Save rejected variants too; searching many variants increases the chance of finding an accidental winner.
- Develop only on the first interval. On the validation interval, compare net return after costs subject to the prewritten drawdown constraint. If neither candidate qualifies, select neither. Record trade count and result concentration alongside the ranking.
- Freeze the selected code and inputs before opening the final holdout. Report that result even if it disappoints. Changing the strategy after seeing it turns that interval into development data; a fresh holdout is then needed.
- For walk-forward testing, predefine training and following test windows. At each step use only earlier data to choose settings, then join the non-overlapping test results. Keep warm-up, flat-start and liquidation conventions consistent.
Use a scorecard instead of one headline number
Keep one record per candidate, period and cost scenario. Include code version, symbol, timeframe, capital, size, inputs and fill settings so another person can rerun it. The comparisons below are proposed checks; no test results have been measured for this page.
- Net return and benchmark: compare after-cost return with buy-and-hold over the same dates, and report time in market and exposure. A lower drawdown while holding mostly cash is not an equal-exposure comparison.
- Drawdown and duration: record both the depth of equity declines and the time below a previous peak. A historical maximum is an observation, not a bound on future losses.
- Trade count and concentration: show closed trades, average net trade, and the contribution from the largest winners. Many correlated trades in one regime do not establish independent evidence across regimes.
- Profit factor and win rate: profit factor divides gross winning profit by gross losing loss. Interpret it with average win/loss and costs. With no losing trades it is not a useful finite ratio. There is no universal profit-factor threshold or trade count that proves a durable edge.
- Sensitivity: on development and validation data, compare nearby parameters and higher costs. An isolated peak deserves investigation; a broad stable region is supporting evidence, not protection from overfitting.
Forward-test the unchanged script
Run the frozen candidate as new bars arrive and retain timestamped signal and simulated-fill records. Compare them with the written rules and check whether trades move after a reload. TradingView distinguishes this forward simulation from testing historical bars.
- Pine strategies cannot place orders directly in TradingView Paper Trading or brokers connected through the Trading Panel. Strategy order-fill alerts record emulator events; they are not broker fill confirmations.
- If you manually mirror signals in Paper Trading, record submission delay and the resulting paper fills separately. That evaluates a different execution workflow and still does not establish live liquidity or slippage.
- Choose the observation period and review criteria beforehand. Fifty or one hundred trades is not a universal pass condition. Record missed signals, outages, changes in market conditions and any implementation correction.
Pineify next step
Compare parameters after the rules pass your audit
Strategy Optimizer can compare parameter combinations for an existing TradingView strategy. Use Backtest Deep Report to examine a supported trade export. Premium Scripts supplies source-code indicators and tutorials; an indicator still needs explicit order and exit rules before strategy testing. These tools do not establish future profitability.
Sources and verification
Last verified:
This guide is educational and is not investment advice. The example rules have not been backtested for this page. Historical and simulated results do not guarantee future returns or live execution quality.