TradingView backtesting

Monte Carlo trading simulation: resampling and limits

Monte Carlo simulation in trading generates alternative outcomes under a stated model. Shuffling a fixed list of cash profits and losses changes the equity path but preserves its ending balance. Bootstrap sampling with replacement can change both. Neither method predicts future prices or proves that a strategy has an edge. Pineify Backtest Deep Report uses the bootstrap approach on TradingView trade CSV data.

Open Backtest Deep Report

Choose the randomization before choosing a tool

A simulation is only interpretable when its random input is explicit. SciPy describes bootstrap resampling as drawing with replacement from the original sample. A shuffled sequence instead uses every observation once. Changes to execution costs, strategy parameters or market regimes require additional assumptions and a different experiment.

MethodWhat changesWhat stays fixedQuestion it answers
Permutation / shufflingOrder of existing tradesTrade count and each cash P&L; therefore total P&LHow much can the path deteriorate when the same losses cluster?
Independent bootstrapOrder and frequency of sampled trades; repeats and omissions occurEmpirical set of possible single-trade outcomes and chosen horizonHow do outcomes vary if trades are independent draws from this sample?
Block bootstrapSequence of groups of consecutive observationsSome local dependence within each sampled blockHow sensitive is the result when nearby losses stay together?
Parametric or execution stress modelDraws from specified distributions, or reruns with changed assumptionsOnly the assumptions explicitly held constantWhat happens under this particular volatility, cost or parameter scenario?

Four trades: identical ending equity, different drawdowns

This illustrative calculation starts with $1,000 and uses fixed cash P&L after assumed costs: +$200, -$100, +$200, -$100. Equity equals initial capital plus cumulative P&L. Percentage drawdown at each step is (running peak minus equity) / running peak. There are no deposits, withdrawals, resizing or trading halts.

  • Every permutation ends at $1,200 because addition is order-independent. A shuffle cannot turn this fixed cash trade list into a negative total return.
  • The bootstrap row repeats a loss and omits wins. Its total P&L changes because the sampled trade mix changes.
  • Reordering fixed percentage returns also preserves their compounded product when all trades execute. Capital limits, resizing rules and early stopping can break that equivalence.
  • These are arithmetic examples, not measured strategy results. Closed-trade paths do not reconstruct losses inside an open trade.
SequenceEquity after each tradeFinal equityMaximum drawdown
Original: +200, -100, +200, -100$1,200, $1,100, $1,300, $1,200$1,200 (+20%)$100; 8.33%
Shuffle: +200, +200, -100, -100$1,200, $1,400, $1,300, $1,200$1,200 (+20%)$200; 14.29%
Bootstrap draw: -100, -100, -100, +200$900, $800, $700, $900$900 (-10%)$300; 30%

A small exact distribution you can check

In the four-trade sample, an independent draw has a 1/2 chance of +$200 and a 1/2 chance of -$100. With four draws and W wins, final equity is $600 + $300 × W. The table enumerates all 16 equally likely win/loss sequences, so it has no Monte Carlo sampling error. Its probabilities belong to this deliberately small model.

  • The model probability of ending below $1,000 is 5/16 = 31.25%. It is not an estimate backed by a representative trading history.
  • Using the inverse empirical CDF convention, the 5th-percentile final equity is $600: the first value whose cumulative probability reaches 5%. Other percentile conventions may interpolate.
  • Ending balance is not path survival. From $100, the sequence -$150 then +$200 ends at $150 but touches -$50 first. A real account could be unable to take the second trade.
Wins in four drawsFinal equityNumber of sequencesModel probability
0$6001 of 166.25%
1$9004 of 1625%
2$1,2006 of 1637.5%
3$1,5004 of 1625%
4$1,8001 of 166.25%

What a 95% label can and cannot establish

An upper 95th-percentile drawdown summarizes the simulated drawdown distribution. A lower 5th-percentile ending return summarizes a different distribution. A confidence interval for an estimated statistic is another object. None alone gives a 95% guarantee that future equity will stay inside a plotted band at every step.

  • Specify the statistic: cash drawdown, maximum percentage drawdown, terminal return or probability of crossing a capital threshold. They answer different questions.
  • Specify the quantile rule. For 1,000 sorted results, Pineify selects zero-based index 950 for its 95% drawdown field and index 50 for its lower-return field: the 951st and 51st observations.
  • More simulation runs reduce numerical sampling variation conditional on the model. They do not add unseen market regimes or repair biased trades.
  • Do not call the worst sampled path a worst possible outcome. A future loss can exceed every observation in the input data.

Check dependence, missing tails and sizing assumptions

Independent bootstrap draws treat the trade sample as a stable outcome distribution without serial dependence. That assumption is doubtful when trades overlap, volatility changes or several losses arise from the same market event. The arch documentation provides stationary and fixed-length block bootstraps for time-series data; block length is itself a modeling decision.

Failure conditionWhy the simulation can misleadFollow-up check
Loss clustering or overlapping positionsIndependent draws remove the observed dependence.Compare several block lengths; preserve joint timestamps for portfolio analysis.
A rare loss never appears in the sampleResampling cannot invent a larger single-trade loss.Run explicit gap, cost and liquidity stress scenarios separately.
Parameters selected on the same tradesResampling reuses the selected sample and does not undo selection bias.Freeze rules and evaluate an untouched period.
Historical position sizes change through timeCash P&L mixes market outcomes with the original sizing decisions.State whether the intended model uses cash, returns or risk units, then model resizing explicitly.
Intratrade or margin risk mattersTrade-close P&L misses interim exposure and liquidation rules.Use a simulator with the required price path and broker constraints.

Run the TradingView CSV workflow in Pineify

Backtest Deep Report reads TradingView List of Trades CSV data. TradingView exports each Strategy Report tab separately, so a Performance Summary CSV or OHLC price file is not the required trade list. The report includes the original equity curve in Charts and a separate Simulation view. Importing your own data currently requires Advanced or higher; the app also provides demo data.

  • 1. Save the strategy version, symbol, timeframe, date range, capital, sizing, commission and slippage assumptions. Check for lookahead and repainting before exporting.
  • 2. Download List of Trades from TradingView, import it and reconcile the trade count and net P&L. Confirm initial capital, direction filter and the open-trade setting.
  • 3. Review the original equity curve, open Simulation and click Run Simulation. After changing the input or settings, run the simulation again.
  • 4. Compare the modeled outcomes with your specified capital threshold and record limitations. Keep the original CSV and report output with your research notes.

Read the current report implementation precisely

The current engine takes 1,000 independent bootstrap samples of the selected net cash P&L values, each as long as the input list. It adds each sampled value to initial capital and displays the first 50 paths. The app may describe this as reshuffling, but trades are sampled with replacement. It does not rerun strategy entries, resize positions, model new prices or offer block sampling.

Report detailCurrent meaningInterpretation limit
Drawdown fieldsPercentage decline at the point of the largest cash drawdown in each path, then ranked across runsThis can differ from the largest percentage drawdown, which may occur at a different equity peak.
Min Return (95%)Lower-tail ending return selected from the 1,000 final balancesA conditional sample quantile, even if the UI calls it confidence.
Risk of RuinFraction of simulations whose final equity is zero or negativeDoes not count every path that crosses zero earlier and later recovers; does not model margin liquidation.
Random seed and replayUses unseeded random draws; no seed control in the current interfaceReruns can differ. Saving the input alone does not reproduce an exact run.

Keep an audit record for reproducible comparisons

A reproducible simulation record needs the input file or hash, filtering rules, capital, P&L units, sampling method, horizon, run count, random generator and seed, quantile convention, drawdown definition and stopping rule. SciPy exposes a random generator input for repeatable bootstrap behavior. Pineify currently has no seed control; record that limitation rather than inventing a seed for an existing run.

  • Separate model changes from random variation. Compare the same input under named assumptions and retain the actual outputs.
  • If exact replay, block resampling or a path-crossing ruin model is required, use an implementation that exposes those controls. The current Pineify report is a starting analysis of the supplied trades.
Where Pineify fits

Backtest Deep Report

Inspect the original TradingView trade record and run the existing 1,000-sample bootstrap analysis. Review its cash-P&L, drawdown and terminal-ruin definitions before using the result. Demo data is available; importing your own CSV requires Advanced or higher.

Open Backtest Deep Report

Frequently asked questions

Educational analysis, not investment advice. Examples are hypothetical calculations. Simulated probabilities depend on the input sample and model; actual losses can exceed them. Pineify is independent of TradingView.

Sources and verification