To backtest a strategy in TradingView, write the rules in Pine Editor, click "Add to chart," and read the Strategy Tester pane for max drawdown, profit factor, win rate, and net profit. The free plan covers daily-timeframe testing on Indian indices going back to 2008 — no coding background required.
Most retail traders bet real money on strategies they've never actually tested. They read about a setup on YouTube, see one good chart, and start risking their own capital on it.
There's a free tool that can stress-test the same idea against fifteen years of Nifty data in an afternoon. Almost nobody bothers to use it.
That tool is TradingView. The reason I keep recommending it isn't price (the free plan is enough for everything in this article). It's the data.
Before TradingView, finding clean historical data on Indian indices going back to 2008 was genuinely hard. Now it's two clicks.
This article walks through one full backtesting cycle on a real strategy. Build it, test it, find what's broken, fix it, test it again. Once you've seen the loop run on one strategy, you can run it on anything.
The reality checkWhy Most Retail Traders Skip This
Backtesting is checking whether a strategy would have worked in the past. Two words: back, testing. You take an idea, apply it to historical data, and find out whether it would have made money or lost it.
Logically, this is where every new trader should start. In practice, almost none of them do.
The biggest reason isn't laziness — it's a mental block. Most retail traders assume backtesting is technical, expensive, requires coding, requires data subscriptions. None of that is true anymore.
The whole loop, on the free plan, takes a couple of hours.
The cost of skipping it shows up later. You end up paying tuition to the live market for what TradingView would have told you for free. That ₹50,000 you lost in your first six months trying out a setup from a YouTube video could have been a thirty-minute backtest.
Trading without backtesting
No data, just hopeYou read about a strategy, the chart looks convincing, you trade it. Every losing trade teaches you something, but you're paying live-market prices for the lesson. Six months later, you find out the strategy was broken from day one.
Trading with backtesting
Tested before riskSame strategy, same idea. You simulate it across fifteen years of data first. The metrics tell you whether it would have worked, where it would have hurt, what to fix. You stop testing strategies on your own bank balance.
It's the same gap as a pilot's first flight being with passengers versus a hundred hours in a simulator. Same skill being learned. Wildly different cost of getting it wrong.
Step 1The Strategy We're Going to Test
We'll use the moving average crossover on Nifty futures. It's not a secret strategy. It's been around for decades.
The reason I'm using it is exactly because it's simple and well-known. That lets the workflow be the focus, not the strategy.
The rules are straightforward. Two moving averages: a 20-day and a 50-day. When the 20-day crosses above the 50-day, go long Nifty futures. When it crosses below, exit the long and open a fresh short.
Simple or exponential moving average, doesn't really matter. Daily timeframe. That's the whole strategy.
This is a basic trend-following system. The crossovers signal that momentum is picking up on the upside or downside.
I'm picking Nifty futures because TradingView's Nifty data goes back to 2008. That's fifteen-plus years across the GFC recovery, the 2014–17 bull run, the 2018 vol return, the 2020 Covid crash, the 2022 rate-hike cycle. A backtest across that range stresses a strategy in ways no demo account ever could.
Why backtesting on the free plan still works. TradingView's BASIC tier limits you to daily-timeframe backtests on most instruments. For a swing strategy on Nifty futures, that's exactly the right resolution. Intraday backtesting needs a paid plan, but that's a problem for later.
Setting It Up: Pine Editor and Strategy Tester
TradingView has two panes that matter for backtesting. The Pine Editor is where the strategy code lives. The Strategy Tester is where the results show up after you click "Add to chart."
I'm not going to teach you Pine Script in this article. That's a separate piece.
For now, take it on faith that the strategy code does four things: defines the two moving averages, sets the long-entry rule (20 crosses above 50), sets the short-entry rule (20 crosses below 50), and points the test window at 2007 onward. Click "Add to chart." TradingView simulates every trade the strategy would have taken across the full data range.
You'll see long and short trade markers plotted right on the chart. The two MA lines overlay the price.
At the bottom, three tabs in the Strategy Tester pane: Overview, Performance Summary, and List of Trades. Most of the answers live in the first two.
Step 3The Six Metrics That Actually Matter
TradingView throws a dozen numbers at you in the Strategy Tester. Most of them are noise. Six of them tell you almost the entire story, and the order you read them in matters more than people think.
Most beginners read the net profit first, get excited, and stop. That's exactly backwards. Net profit on its own is the least informative metric of the six. Here's the order I read them in.
How Much Each Metric Should Weigh
Max drawdown is the percentage your account fell from its peak before recovering. It's the metric that decides whether you can actually trade the strategy.
A 50% drawdown means you'd need a 100% gain to get back to even. Most traders quit before that math works out.
Profit factor is gross profit ÷ gross loss. Above 1 means profitable. Above 2 means strong. It tells you how much each winning trade pays for each loser.
Buy-and-hold benchmark is the question every active strategy has to answer: would a passive investor doing nothing have made more money? If yes, your effort is wasted twice: once on the missed returns, once on the time.
Win rate is what beginners obsess over. A 36% win rate sounds bad until you check the profit factor. A 70% win rate sounds great until you find out the average winner is smaller than the average loser.
On its own, win rate tells you very little.
Step 4Reading the Numbers and Finding the Faults
Here's what the Strategy Tester returned on our v1 backtest, run through that filter.
Net profit: +478.51%. Total trades: 57. Both reasonable on the surface. With only 57 trades over fourteen years, commissions and slippage stay small.
Win rate: 36.84%. Surprisingly low. But the profit factor came in at 2.13. Each winning trade more than covered two losers.
The wins were small in count but big in size. That's a perfectly fine shape for a trend-following system.
A 36% win rate doesn't mean a bad strategy. A profit factor of 2 means each winner paid for two losers. The first sign that a strategy is working isn't its win rate — it's whether the math behind the wins covers the math behind the losses.
Max drawdown: 52.29%. Stop here. This is the problem.
At some point in those fourteen years, the account was down 52% from its peak. To recover from a 52% drawdown, you need a 109% gain.
Most traders abandon a strategy long before it claws back from there. Our math says profitable. Our nerves say "I'm out by month four."
Buy-and-hold benchmark: ~300%. The strategy made 478% over the test window. A passive investor doing nothing made roughly 300%. The strategy wins — but barely, and it took 57 trades to get there while buy-and-hold took zero.
Long vs short P&L. This is where it gets uncomfortable. Of the ₹8.99 lakh gross profit, roughly ₹7 lakh came from longs and only ₹2 lakh from shorts.
The shorts were essentially flat. The strategy is a long-only system pretending to be bidirectional.
That's three faults to fix:
Fault #1 — drawdown of 52% is unacceptable. Highest priority.
Fault #2 — short trades aren't pulling weight. The strategy is leaving half the market untraded.
Fault #3 — win rate of 37% is borderline. Defensible because of the profit factor, but worth improving if it doesn't hurt the other metrics.
The mechanicsThe Drawdown Question That Trips Everyone Up
One more thing about that drawdown chart. TradingView shows the y-axis going down to -200%, -300%, even -400%. People always ask the same question: how can you lose more than 100% when the most you put in is your capital?
In cash equity, you can't. Worst case, your stock goes to zero. That's a 100% loss, full stop.
But this backtest is on Nifty futures, and futures use leverage.
In Nifty futures (or short options positions), a single trade can lose more than the cash you put up to open it. That's why the y-axis on a futures backtest can show -200%, -300%, or worse: it's mathematically possible to be wiped out and still owe money. The leverage that lets you control a ₹15 lakh position with ₹1.5 lakh of margin works exactly the same way on the way down.
The answer to "can you lose more than your capital?" in futures is yes. That's exactly why position sizing matters more than entry signal — and why a 52% drawdown should be a red flag, not a curiosity.
Step 5Fixing the Strategy: Version 2
Three faults, three targeted fixes. Not to the core idea of crossover trading, but to the parameters and conditions around it.
Different MA lengths. An asymmetric entry condition for shorts. A basic trend filter so the strategy doesn't fight a strong move. (The exact code is its own video.)
I rewrote the strategy with those changes, hit "Add to chart," and pulled the same six metrics from the same Strategy Tester pane.
Backtest Results: v1 → v2
All three faults addressed without breaking the rest.
All three faults addressed. Drawdown dropped from 52% to 32% — still high, but in the realistic range a trader can sit through.
Shorts now contribute. Win rate climbed to 47%. None of these came at the cost of net profit, which actually went up by 100 percentage points.
That last bit matters more than it sounds. Parameter tweaks usually trade one metric for another. When all metrics improve together, it's a sign you fixed the right thing rather than just curve-fitting.
That's not a perfect strategy. It's a better one.
Run the loop again. Find the next three faults. Fix them. That's the entire game — backtest, identify, fix, re-test, until the strategy is good enough to risk real money on.
VRD Strategies is our library of pre-built, rule-based strategy frameworks with entries, exits, position sizing, and stop logic already specified. Building strategies from scratch and then iterating on them is the slow path. Pick a tested framework, plug it into TradingView the way this article describes, and spend your time on the parameters that actually matter.
Backtesting Is the Entry Point, Not the Destination
Backtesting tells you what would have worked. It doesn't tell you what works now, and it doesn't tell you whether you can execute. There are two more steps after backtesting before a strategy is truly yours.
Forward-testing means running the strategy on live data without putting money on the line. It tells you whether the strategy still works in the current regime.
Markets shift. A strategy that printed money 2014–2018 might be flat 2024–2026. Forward-testing catches that drift.
Paper trading means executing every signal in real time on a paper account. It tells you whether you can actually pull the trigger.
Backtests run in the calm of a chart at midnight. Real trades happen at 9:17 AM with adrenaline running. Plenty of strategies that backtest beautifully fall apart in execution.
Backtesting is the cheapest filter. Forward-testing is the second cheapest. Live trading is the most expensive. Use them in that order.
Most retail traders skip the first two and pay the price at the third.
The Whole Loop Is Free
The reason I wrote this article isn't to teach you everything about backtesting in a single sitting. It's to remove the mental block that keeps most retail traders from ever testing a strategy at all. The whole loop is free: a laptop, a TradingView account, an afternoon.
Whatever strategy is sitting in your head right now, untested, that you've been planning to "try with small capital," test it first. The cost of finding out it doesn't work is zero. The cost of finding out the same thing in your trading account is whatever you risked.
Where backtesting fits in your toolkit
Now Learn What's Worth Testing
Backtesting answers "would this have worked?" — the courses answer the harder one: which strategies belong in your library in the first place? Both programs are taught live by VRD Rao, with batch sizes capped so every student gets answered.
Elite Traders Program
6 MONTHSThe 6-month foundation — strategy frameworks, risk management, and the exact backtesting workflow from this article applied to a full curriculum of setups.
- Live sessions with VRD Rao
- 200+ hours recorded content
- Batch size capped at 25
- Personal trade reviews
Ultimate Traders Program
12 MONTHSEverything in Elite plus a full year of advanced strategy work — algo, options, intraday — and 150+ hours of live trading alongside VRD Rao.
- Everything in Elite, plus:
- 150+ hrs live trading sessions
- Algo & advanced options masterclass
- Investing masterclass