PineScript Indicator vs Strategy: What Is the Difference?
In Pine Script, an indicator draws information on your chart, while a strategy also simulates buying and selling so you can backtest it. Both are scripts, and the first difference is the declaration line: an indicator starts with indicator(), a strategy starts with strategy(). An indicator can show moving averages, highlight zones, or fire alerts, but it never keeps track of trades or a simulated account. A strategy adds special commands like strategy.entry and strategy.exit, and TradingView then produces a Strategy Tester report showing hypothetical profit, win rate, and drawdown over past data. Use an indicator when you just want context on the chart. Use a strategy when you want to test how a set of rules would have performed. A strategy's backtest is a study of the past, not a promise about the future.
The structural difference between PineScript indicator scripts and strategy scripts, and when each type is appropriate.
Key points
- An indicator visualizes information on the chart, while a strategy also simulates entries and exits so it can be backtested.
- The declaration line gives it away: indicator() versus strategy() at the top of the script.
- Strategies use commands like strategy.entry and strategy.exit that indicators simply don't have.
- Only a strategy produces TradingView's Strategy Tester report with hypothetical performance numbers.
- Indicators can send alerts and color the chart, which is often all a discretionary trader needs.
- A strategy's past results are a research view of history, never a guarantee of what will happen next.
Frequently asked questions
Can a Pine Script indicator place trades?
No. Indicators only draw on the chart and can send alerts. To simulate buys and sells and get a backtest report, you need a strategy, which has the entry and exit commands an indicator lacks.
How do I know if a script is an indicator or a strategy?
Look at the first declaration line. If it says indicator(), it's an indicator. If it says strategy(), it's a strategy and you'll also see a Strategy Tester tab appear when you add it to a chart.
Can I turn an indicator into a strategy?
Often yes. You switch the declaration from indicator() to strategy() and add entry and exit commands where your buy and sell conditions are. It takes some rewriting, but the underlying logic can usually be reused.
Why does the Strategy Tester only appear for some scripts?
Because it only shows for strategy() scripts. Indicators don't track a simulated account, so there's nothing to report. If you want the tester, the script has to be written as a strategy.
Which one should I build first as a beginner?
Usually an indicator, to get comfortable with the language and the chart. When you want to test rules, Agenticks' AlgoAgent can generate either a Pine Script indicator or a testable strategy from a plain description and run a backtest for you to review. It's for learning, not a profit promise.
Related on Agenticks
This content is for educational purposes only and does not constitute financial advice. Trading involves risk, including possible loss of capital.