Lesson 37 of 50

Pine Script Indicators vs Strategies Explained

The difference between a Pine Script indicator (purely visual) and a strategy (backtestable via Strategy Tester) - plus a caveat about backtested results.

What you will learn in this lesson

  • Understand the difference between a Pine Script "indicator" and a "strategy"
  • Learn that indicators are purely visual, while strategies can be backtested
  • Understand what TradingView's Strategy Tester does, conceptually
  • Recognize an honest, important caveat about interpreting backtested results
  • Prepare for Lesson 38's first minimal example of actual Pine Script syntax

Lesson 36 introduced Pine Script as TradingView’s own scripting language. Before looking at any actual code, there’s an important fork in the road worth understanding first: every Pine Script is written as one of two broad types - an indicator or a strategy - and the two behave quite differently.

Indicator Scripts: Purely Visual

An indicator script calculates something and displays it on the chart - a line, a shaded band, a marker, a label - but it does not simulate placing or managing any trades. Everything covered in Module 5 (EMA, RSI, MACD, Bollinger Bands, and the rest) works this way conceptually, whether built into TradingView or custom-written: calculate, then display.

If your goal is simply “I want to see my own custom calculation plotted on the chart,” an indicator script is the appropriate type.

Strategy Scripts: Backtestable

A strategy script goes a step further: it defines simulated entry and exit rules - for example, “enter a simulated long position when price crosses above a moving average, exit when it crosses back below.” Because a strategy script defines these rules explicitly, TradingView can run it through the Strategy Tester, simulating how that exact rule set would have performed against historical price data.

   Indicator Script                      Strategy Script
   ─────────────────                     ─────────────────
   Calculates + plots something          Defines simulated entry/exit
   on the chart                          rules for trades
        │                                       │
        ▼                                       ▼
   No trade simulation involved          Can be run through the
                                          Strategy Tester for
                                          backtested performance

What the Strategy Tester Actually Shows

Running a strategy script through the Strategy Tester produces simulated performance statistics - things like the total number of simulated trades, an approximate win rate, and overall simulated profit or loss across the historical period tested. This is conceptually similar to the paper trading practice from Module 9: no real money changes hands, but the exercise builds a rule-tested track record instead of a purely subjective impression.

An Honest Caveat About Backtested Results

This is the single most important point in this lesson: a strategy performing well when backtested against historical data is not a guarantee that it will perform similarly going forward. A backtest reflects how a specific set of rules would have behaved under the exact historical conditions tested - price action, volatility, and market behavior can shift over time, and future conditions are never guaranteed to resemble the past closely enough for identical results to repeat.

This doesn’t make backtesting worthless - it can still reveal whether an idea has any historical basis at all, and roughly what its past drawdowns looked like. It simply means a strong backtest is useful context, never proof of future performance.

Real-Life Example: Two Traders, Two Goals

Suppose one trader wants to plot a custom volatility band on their Nifty chart, purely to visually assist their own manual decision-making - no backtesting needed, no simulated trades. An indicator script is exactly right for this.

A second trader has a specific rule in mind - “buy when price closes above the 20-period EMA with rising volume, sell when it closes back below” - and wants to know how often, historically, that rule would have worked on Bank Nifty over the past two years. This calls for a strategy script, run through the Strategy Tester, to see simulated historical performance for that exact rule.

Both traders are using Pine Script - but for genuinely different purposes, matching the type of script to the goal.

Analogy: A Dashboard Gauge vs a Flight Simulator

Think of an indicator script like a dashboard gauge in a car - it displays useful information (speed, fuel level) but doesn’t drive anywhere on its own. A strategy script is more like a flight simulator - it lets you run a specific set of maneuvers against realistic historical conditions to see how they would have played out, before ever getting into a real cockpit. The simulator is genuinely useful practice, but performing well in it still doesn’t guarantee identical results in the unpredictability of an actual flight.

Common Beginner Mistakes

  • Treating a strong backtest as a guarantee of future performance. It reflects historical conditions specifically - a genuinely important distinction, not a technicality.
  • Writing a strategy script when an indicator would do. If the only goal is visual display, adding unnecessary simulated trade logic overcomplicates the script.
  • Assuming the Strategy Tester risks real money. It’s a historical simulation tool - no real capital is involved unless a script is separately and deliberately connected to a live account, a topic well beyond this lesson.
  • Ignoring a poor backtest result out of attachment to an idea. A weak historical result is genuinely useful information, worth taking seriously rather than dismissing.

Practical Exercise

  • Without writing any code, decide: if you wanted to simply plot a moving average line on your chart, would that need to be an "indicator" or a "strategy" script? What if you wanted to see how many times, historically, a specific crossover would have resulted in a profitable trade?
  • Write 2-3 sentences in your own words explaining why a strategy performing well on historical data is not, by itself, a guarantee of future performance.

Mini Quiz

1. What is the primary purpose of a Pine Script written as an "indicator"?
  • To automatically place real trades
  • To calculate and visually plot something on the chart, without simulating trade entries or exits
  • To replace the need for a broker account
  • To send webhook messages directly

An indicator script is purely visual - it calculates and plots something on the chart (a line, a shaded area, a signal marker), but does not simulate placing or managing trades.

2. What can a "strategy" script do that a plain "indicator" script cannot?
  • Nothing - they are functionally identical
  • It can be backtested using TradingView's Strategy Tester, simulating how a set of buy/sell rules would have performed on historical data
  • It automatically executes real trades with real money, with no further setup
  • It removes the need for any chart at all

A strategy script defines simulated entry and exit conditions, which TradingView's Strategy Tester can then run against historical price data, showing simulated past performance - something a purely visual indicator script does not do.

3. Does a strategy script placing simulated trades in the Strategy Tester mean real money is being risked?
  • Yes, real money is automatically risked the moment a strategy script is written
  • No - the Strategy Tester simulates trades against historical data; no real money or live orders are involved unless separately and deliberately connected to a live account
  • Strategy scripts can only be tested with real money
  • This depends on which broker is used

The Strategy Tester is a simulation tool - it shows how a defined set of rules would have performed on historical data, similar in spirit to the paper trading concept from Module 9, without risking real money on its own.

4. Why is it important to be cautious when interpreting a strategy's backtested results?
  • Backtested results are always identical to future real-world performance
  • Historical performance reflects how a strategy would have performed on past data specifically, which is not a guarantee of how it will perform going forward under different future conditions
  • Backtesting is illegal for retail traders
  • Strategy Tester results cannot be viewed by the person who wrote the script

A strategy that performed well on historical data reflects how it would have done under THAT specific past data - markets change, and future conditions are never guaranteed to resemble the past closely enough for identical results to repeat.

5. If a trader simply wants to plot a custom moving average calculation on their chart with no backtesting involved, which type of Pine Script would be appropriate?
  • A strategy script exclusively
  • An indicator script, since the goal is purely visual and doesn't involve simulating trade entries or exits
  • Neither type can plot a moving average
  • This requires a separate, non-Pine Script tool entirely

Since the goal here is purely visual (plotting a calculation on the chart) with no simulated buying or selling involved, an indicator script is the appropriate choice - strategies are specifically for when backtested trade simulation is the goal.

Frequently Asked Questions

Can a single Pine Script be both an indicator and a strategy at the same time?

A given script is written as one type or the other from the start (declared near the top of the script, touched on conceptually in Lesson 38) - it's either built to plot visually (indicator) or to simulate trade entries/exits for backtesting (strategy), not both simultaneously in one script.

Is a strategy script more "advanced" than an indicator script?

Generally, yes, in the sense that a strategy needs additional logic (defining exactly when a simulated trade opens and closes) beyond what a purely visual indicator requires - though both types share very similar underlying Pine Script fundamentals, covered together in this module.

What exactly does TradingView's Strategy Tester show?

It shows simulated performance statistics - such as total simulated trades, win rate, and profit/loss - based on running a strategy script's defined rules against historical price data. It's a way to evaluate a rule-based idea without risking real money, conceptually similar to the paper trading practice from Module 9.

Does a good backtest result mean a strategy is guaranteed to work going forward?

No - this is one of the most important cautions in this entire module. A backtest reflects how a strategy would have performed specifically on historical data; markets can and do behave differently in the future, so past performance on historical data is never a guarantee of future results.

Why would anyone bother backtesting at all, if it isn't a guarantee of future performance?

Backtesting still offers genuine value - it can reveal whether a rule-based idea has any historical basis at all, roughly how often it might have worked, and what its historical drawdowns looked like - useful context, just not a guarantee, similar in spirit to how paper trading (Module 9) builds familiarity without guaranteeing future real-money results.

Do I need to write a strategy script to use Pine Script at all?

No - many traders write only indicator scripts, simply to visualize custom calculations or conditions on their charts, without ever using the Strategy Tester or writing strategy-specific logic.

Is backtesting on TradingView free to use?

Running a strategy script through the Strategy Tester is generally available on TradingView's free tier, subject to TradingView's current plan limits - always check TradingView's current plan details directly, since these can change.

Can a strategy script's backtested signals be turned into live alerts?

Yes, conceptually - strategy scripts commonly generate the alert conditions covered in Module 8, which Module 11 (starting in Lesson 39) explains can be connected to webhooks. This lesson focuses specifically on the indicator-vs-strategy distinction; the alert/webhook connection is covered fully ahead.

What happens if a strategy performs poorly in backtesting?

That's a genuinely useful outcome to know before ever considering real capital - a poorly performing backtest is a signal to reconsider or refine the underlying rules, rather than proceeding as if the idea were already validated.

How does this lesson connect to Lesson 38 next?

This lesson establishes the conceptual difference between indicators and strategies. Lesson 38 gets hands-on (in plain English) with a first minimal example script, showing what a few actual lines of Pine Script look like and what each one does.

Key Takeaways

  • An "indicator" script is purely visual - it calculates and plots something on the chart, without simulating trade entries or exits.
  • A "strategy" script defines simulated entry and exit rules, which can be backtested using TradingView's Strategy Tester against historical data.
  • The Strategy Tester simulates performance on historical data - it does not risk real money on its own, similar in spirit to paper trading from Module 9.
  • Past performance on historical data is not a guarantee of future results - markets can and do behave differently going forward.
  • Backtesting still offers genuine value (revealing whether an idea has historical basis) even though it isn't a guarantee - context, not certainty.
  • Strategy scripts commonly generate the alert conditions that Module 11 connects to webhooks - a link explored starting in Lesson 39.

Conclusion

Knowing whether you're building something purely visual (an indicator) or something backtestable (a strategy) shapes how you think about a Pine Script from the very first line. With that distinction clear - and the honest caveat about backtested results in mind - the next lesson finally looks at a few actual lines of Pine Script, explained one at a time in plain English.

Disclaimer:This lesson is for educational purposes only and covers the TradingView platform itself - it is not investment, trading, or financial advice. No indicator, drawing tool, or automation setup guarantees future results. Trading and investing involve risk of loss and are not suitable for every investor. Please do your own research and consult a SEBI-registered investment adviser before making trading or investment decisions.