
What Is Pine Script? A Plain-English Guide to TradingView's Language
The code behind every custom indicator and strategy on TradingView, explained without the jargon and without turning you into a programmer.
The Strategy Tester, Bar Replay, the metrics that actually matter, and the repainting trap that makes bad strategies look perfect.
Anyone can make a strategy look like a money printer. Curve-fit a few settings, cherry-pick a bull market, ignore fees, and suddenly the equity curve points straight to the moon. Learning how to backtest a strategy on TradingView properly is mostly about learning how not to lie to yourself, because the tools will happily help you do exactly that if you let them.
TradingView gives you two honest instruments for this: the Strategy Tester and Bar Replay. Used carefully, they tell you whether an idea has legs. Used carelessly, they hand you a beautiful backtest that blows up the moment real money touches it. Here is how to run one that you can actually believe.
The Strategy Tester only works with a strategy script, not a plain indicator. In Pine Script terms, a strategy is code that declares entries and exits, so TradingView can simulate the trades. If you are using a built-in strategy or a published one, add it to your chart from the Indicators window like any other script, and the tester panel appears at the bottom.
That panel has a few tabs worth knowing:
Set your date range deliberately. Testing only the last year of a raging bull market proves nothing except that buying worked when everything went up. You want a range that includes at least one ugly period.
The Strategy Tester shows you the whole history at once, which is convenient and also a little dangerous, because your brain quietly cheats. You already know what happened next, so every signal looks obvious in hindsight.
Bar Replay fixes that. It lets you rewind the chart to a past date and step forward one bar at a time, revealing price the way it actually arrived: with the future hidden. You pick a start point, then advance bar by bar and watch how the strategy behaves when it genuinely does not know what comes next.
This matters for two reasons. First, it is the closest thing to live trading you can get without waiting weeks. Second, and this is the big one, it is how you catch an indicator that is lying to you about the past.
Win rate is the number beginners obsess over and it is close to useless on its own. A strategy can win 90 percent of the time and still lose money if the 10 percent of losers are enormous. Here is what to actually look at.
| Metric | What it tells you | The trap |
|---|---|---|
| Net profit vs buy-and-hold | Whether the strategy beat simply holding the asset | Beating a flat market is easy; beating a roaring bull market is the real test |
| Max drawdown | The worst peak-to-trough drop in equity | A great return with a 70 percent drawdown is untradeable; you would quit before the recovery |
| Number of trades | Whether the sample is big enough to trust | Ten trades is a coincidence, not evidence |
| Profit factor | Gross profit divided by gross loss | A number just above 1 barely covers costs |
Start with net profit versus buy-and-hold. If a Bitcoin strategy makes less than you would have made by just holding Bitcoin and doing nothing, all that work bought you extra risk for less reward. Buy-and-hold is the benchmark every strategy has to clear.
Then look hard at max drawdown, because that number is really a measure of how much pain the strategy asks you to endure. Most people massively overestimate how much drawdown they can sit through. A curve with a shallower drawdown you can actually hold beats a steeper one you will abandon at the worst moment.
And always sanity-check the number of trades. A strategy with three glorious wins is not a strategy, it is a lucky streak wearing a costume.
If you are backtesting a trend approach on crypto, our Bitcoin trend trading strategy guide walks through the kind of rules that are actually worth testing here.
Now the important part. A repainting indicator is one that quietly rewrites its own history. In real time it shows one thing; then, once the bar closes and the future is known, it goes back and redraws its past signals to line up perfectly with what happened.
The result is a backtest that looks flawless. Every entry is near a bottom, every exit near a top, the equity curve is a straight line to heaven. It is not skill. It is an indicator drawing the answer after peeking at the test. If you trade it live, none of those beautiful signals show up in time, because they only existed in hindsight.
Repainting is the single most common way people get sold a fantasy, and it is worth knowing how to spot it before you ever pay for a tool.
You do not need to read the code. You need Bar Replay and a little skepticism.
This is exactly why the honest standard for any signal tool is: you can backtest it yourself, on your own chart, and it does not repaint. Vektor is built to that standard. It does not repaint, so what you saw is what happened, and it can plot its result right next to buy-and-hold on your chart so you are comparing it against the only benchmark that matters instead of taking anyone's word for it. That last part is the whole point, you should not have to trust a claim you cannot check.
If you are deciding whether the free TradingView tier is enough for this kind of work, our breakdown of free vs paid TradingView plans covers the data limits that affect backtesting. And if you are weighing whether packaged signals are worth it at all, do trading signals actually work is the honest version of that conversation.
A quick, necessary reminder: a backtest is a study of the past, not a promise about the future, trading is risky, and you can lose money. Nothing here is financial advice.
The Strategy Tester is available on TradingView, including the free plan, though the free tier limits how much history and how many bars you can load. That is usually enough to get an honest first read on a strategy. Paid plans mainly buy you more data and more concurrent indicators, not a different tester.
Repainting is when an indicator quietly changes its past signals after the fact, so the backtest shows entries and exits that were never actually available in real time. The result looks flawless because it is cheating: it is drawing the answer after seeing it. Bar Replay and forward testing are how you catch it.
There is no magic number, but three or ten trades tell you almost nothing. A handful of lucky wins can make garbage look brilliant. You want enough trades across different market conditions, trends, ranges, and crashes, that the results are hard to explain by luck alone.
The habit worth building is simple: assume every backtest is guilty until proven honest. Set a fair date range, read drawdown and trade count before you get excited about net profit, and put any signal tool through Bar Replay to make sure it is not redrawing the past. If it survives that, you have something worth a small live test. If it cannot survive that, no marketing page should convince you otherwise.

The code behind every custom indicator and strategy on TradingView, explained without the jargon and without turning you into a programmer.

How to run TradingView on your phone without kidding yourself about what the mobile app can and cannot do versus desktop.

One sells a broad signal toolkit on a subscription. The other sells a single focused trend call for a one-time price. Here is the honest breakdown.