Skip to main content
On this page

Advanced Backtesting: Ratios, Resampling and Rolling Checks

· 9 min read
Pineify Team
Pine Script and AI trading workflow research team

Advanced backtesting checks how a reported result depends on its data, execution assumptions and evaluation method. Sharpe and Sortino ratios summarize aspects of past returns; rolling analysis looks at changes within the sample; Monte Carlo resampling explores outcomes under a chosen model. None establishes the probability that a strategy will keep working.

TradingView already reports Sharpe and Sortino ratios. A separate analysis tool can help inspect a trade list, but it should not be sold on the claim that these metrics are absent from TradingView.

Illustration of advanced backtest analysis, not a verified strategy result

Audit the trades before comparing ratios​

Start with the strategy's source version, input values, symbol, session, chart type, date range, position sizing and cost settings. Then reconcile a selection of entries and exits with the exported trades. An impressive ratio cannot fix an incorrect fill model or future information leaking into a signal.

TradingView uses a broker emulator. Its strategy documentation describes simulated order handling and cautions about synthetic prices on non-standard charts. Keep those assumptions with the report so another reader can reproduce the setup.

Also distinguish different data problems. Selecting only securities that survived to the end of a study can create survivorship bias. A strategy performing differently in a trending and a ranging market is a regime-sensitivity observation; that difference alone is not survivorship bias. Parameter selection on the same data later presented as validation is another separate problem.

Read Sharpe and Sortino on a consistent basis​

Sharpe compares average differential return with the standard deviation of that return series. State the benchmark, return frequency, sample dates and annualization method. An annualized ratio and an unannualized ratio are not directly comparable. William Sharpe's original discussion explains the distinction between historical measurements and expectations, and why time aggregation matters.

Sortino replaces total variability with a downside measure relative to a specified target. The result depends on how that target and downside denominator are defined. This calculation note hosted by CME Group illustrates why using only the count of negative observations versus the full sample changes the result.

Before comparing two reports, record:

Calculation choiceWhat to check
Return observationsDaily or monthly account returns, or individual trade returns?
Benchmark or targetWhat value is subtracted, in which units and for which period?
Downside denominatorDoes it use all observations or only negative observations?
AnnualizationIs the value annualized, and what frequency factor is used?
Missing or flat periodsAre they retained, excluded or filled?

There is no universal Sharpe floor that makes a strategy suitable to trade. A ratio also does not describe the whole distribution: concentrated losses, serial dependence and short samples can make a single number misleading. Computing Sharpe does not itself require returns to be normally distributed; interpreting it as a complete description of risk is the problematic step.

What Monte Carlo resampling actually tests​

A trade-list simulation starts with the outcomes already in the sample. It cannot discover a market event or execution failure absent from both the sample and the model. Record the sampling method, path length, starting capital, cost treatment and position-size assumptions alongside the output.

Pineify's current numerical implementation draws recorded net trade P/L values with replacement, creates paths of the same number of trades, and adds each draw to the starting capital. A trade can appear more than once or be omitted from a path. This is different from merely shuffling every original trade once, which would preserve the final total when sizes are fixed.

That method treats historical trade outcomes as reusable draws. It does not preserve clusters of correlated trades, recalculate signals on a new price path, or model future liquidity. More simulations reduce sampling noise within this model; they do not repair a poor model or biased input data.

A hypothetical percentile example​

The following values are invented to explain interpretation. They are not a Pineify strategy result or an estimate of future loss:

Quantile of a simulated drawdown distributionHypothetical drawdown magnitude
95th percentile18%
99th percentile26%

Under that hypothetical model, approximately 95% of simulated paths have drawdown no greater than 18%, and approximately 99% no greater than 26%, depending on the percentile convention. Drawdowns beyond 26% remain possible in the model. Neither percentile is a maximum loss guarantee or a confidence interval for an unknown real-world drawdown probability.

A label such as "risk of ruin" also needs a definition. In Pineify's current calculation it is the fraction of simulated paths whose final equity is zero or below. It is not the probability of ever touching zero during a path, a broker margin-call model, or an independently calibrated chance of losing the account in live trading.

Use rolling analysis without claiming an early warning lead​

A rolling calculation recomputes a statistic using a moving subset of the observations. Choose the window before inspecting its most favorable result. Overlapping windows share most of their data, so adjacent points are not independent confirmations.

Here is a hypothetical teaching example, using matched calculation conventions in both columns. It is not a gold futures trade record or a screenshot of Pineify output:

MetricHypothetical full sampleHypothetical recent six-month subsetQuestion to investigate
Annualized Sharpe1.80.3Did costs, exposure, volatility or the return distribution change?
Win rate55%48%How many trades are in each sample, and did their average size change?
Maximum drawdown magnitude18%15%Is the equity baseline defined consistently, and is the period still open?

These values are an example of a review prompt, not proof of strategy decay. A change could reflect random variation, a different trade mix, altered settings or execution costs. It does not establish that rolling statistics reliably warn a fixed number of trades before a drawdown.

Pineify's current rolling chart uses 20-trade windows, not six-month windows. Its rolling Sharpe and Sortino values are not annualized, while the overall risk calculations apply a factor based on observed trades per year. Do not compare those displayed values as if they shared a scale. When comparing periods, recompute them using matching definitions.

Analyze a compatible trade list in Pineify​

Backtest Deep Report reads a supported trade CSV and calculates metrics, charts and resampled paths from those trades. It does not rerun the Pine strategy or verify that the original signals and simulated fills were correct. Analysis with your own data is gated to Advanced or above in the current application; check the current plan terms rather than assuming the workflow is free.

  1. Obtain the trade-level report from TradingView and preserve its strategy settings. TradingView's current documentation describes XLSX downloads; available export controls can vary. Pineify's current importer expects CSV, not an XLSX file renamed with a different extension.
  2. If converting a trade worksheet to CSV, retain the headers, entry/exit rows, identifiers, timestamps, currency and P/L fields. Use a compatible format and inspect the import result before trusting the charts.
  3. Set starting capital and the treatment of open trades. Reconcile imported trade count, net P/L and several individual rows with the source report.
  4. Review long, short and combined results where relevant. Read the calculation definitions before comparing ratios with another platform.
  5. Run the resampling view, retain its assumptions, and export the workbook for review. Repeat runs can differ because draws are random.

The local analysis includes an equity curve, return distributions, time-based summaries, rolling statistics and MFE/MAE views when the relevant fields are available. A scatter plot of excursions can suggest questions about exits; it does not establish an optimal stop-loss or take-profit level. Test a proposed exit separately, using prices and information available when the order would have been placed.

CSV reading and the numerical calculations described here run in the browser. That narrow implementation fact does not establish that every application feature or network request is local. Review the current data-handling terms and any optional service before sharing confidential trading information.

Keep an evidence record for each revision​

Save the original export, exact script version, settings, exclusions, cost model and analysis output. If a finding leads you to change a rule, treat the revised rule as a new candidate. Evaluate it on data not used to make that choice, then inspect execution differences during forward observation.

A useful comparison separates at least three questions: whether the trade list is reproduced correctly, whether a proposed change improves the chosen historical criteria, and whether that improvement persists outside the selection sample. Resampling one profitable list answers neither of the latter questions on its own.

Questions about advanced backtesting​

Does a high profit factor validate a strategy?

It describes gross profits relative to gross losses in the supplied sample. It does not establish correct fills, adequate diversification, stable performance or future profitability. Inspect the trades and costs before using it in a comparison.

Are 1,000 simulations enough?

Pineify's current workflow uses 1,000 simulations. That is a configured run count, not a universal reliability threshold. Rare-tail estimates can vary substantially, and increasing the count cannot fix missing events, dependent trades or incorrect sizing assumptions.

Can the same analysis be used for stocks, forex and crypto?

A compatible trade list can be analyzed, but currency, contract size, fees, funding and trading hours still affect interpretation. Reconcile each market's source export separately; a successful import is not validation of its execution model.

Does a low rolling ratio prove the strategy has stopped working?

No. Inspect the sample size, return definition, costs and trade mix. Rolling windows are descriptive and overlap; a short decline alone does not identify its cause or establish a reliable lead over future losses.

Can this tool verify my original Pine Script rules?

A trade-list report analyzes recorded outcomes. Check the original script, signal timing, chart data and broker-emulator settings in TradingView separately. Changing entries or exits requires a new strategy run, not just another resampling of the old list.