What Is a TradingView Strategy? Pine Script vs Indicator (2026)

A TradingView strategy is a Pine v6 script that calls strategy() so the Strategy Tester can simulate orders. How it differs from indicators and alerts, with official docs and academic context.

📖 7 min read

📝 1,346 words

🏷️ Pine Script and TradingView

Share this article:

One line decides what your script can do

Every Pine script declares itself as one of a few kinds, and the declaration is the second line of the file [2]. Two of those kinds matter here:

pine
//@version=6
indicator("My indicator")     // draws on the chart
pine
//@version=6
strategy("My strategy")       // draws, and also trades

The usual explanation is "strategies can be backtested". That is true and it misses the mechanism, which is more useful to know.

strategy() switches on the broker emulator

strategy() does not add a backtest button. It attaches a simulated broker to your script. Everything people associate with a strategy exists because that emulator is running:

What you getBecause
the Strategy Tester panelthere is now a simulated account to report on
strategy.entry(), strategy.exit(), strategy.close()there is something to send orders to
an equity curve and a drawdown figurethe emulator tracks a balance
the List of Tradesthe emulator records its own fills
position state and strategy.closedtradesthe emulator holds positions

That is why you cannot bolt a backtest onto an indicator. An indicator() script has no account, no orders and no position — not because the feature was withheld, but because there is no broker on the other end.

The emulator is a model, and it is worth knowing its assumptions

Because your results come from a simulation, the simulation's rules are part of your results. The two most consequential are documented:

  • On a bar whose range contains both your stop and your target, the emulator infers which came first from where the open sits relative to the high and the low [1]. It is a deterministic rule, not a measurement — the detail is in risk management.
  • If price crosses an order's level inside a gap between bars, the emulator assumes intrabar data does not exist in the gap [1]. So a stop inside a weekend gap does not fill at your stop price.

Neither is a flaw. They are what a simulator has to do when it only has bars. But they mean "the backtest says" is always shorthand for "the emulator, under these assumptions, says".

Two practical consequences

An indicator() marketed as a bot is not one. It can draw arrows and fire alerts; it cannot hold a position or report a drawdown. If a published script's second line says indicator(, no equity curve it shows came from that script.

Converting an indicator to a strategy is not a rename. You have to decide things the indicator never needed: when to enter, when to exit, how much, what happens to an open position when the signal repeats. Pine defaults pyramiding to 1 [1], so that last one has an answer whether or not you chose it.

Those decisions are the actual work, and they are the same ones converting a manual strategy forces into the open.


What a TradingView strategy is not

The word strategy is doing three different jobs in this subject, and running them together is expensive:

  1. a Pine script whose declaration is strategy()
  2. a trading plan — rules, sizing, when you will not trade
  3. an automated system that places orders with a broker

A strategy() script is the first. It is frequently sold as the third.

It does not place orders

This is the boundary worth being precise about. A strategy can raise alerts, and an alert created from a strategy can be set so that order fill events also trigger it [5]. But an alert is a notification. Getting from a fired alert to a filled position needs a broker integration, and the latency between them is yours — it is not in the emulator, which assumed the fill happened at the price it modelled.

And a detail that surprises almost everyone:

Alerts only trigger in the realtime bar. [5]

So a backtest showing two hundred trades produces zero alerts. Every fill in the report is a replay of history; an alert is a realtime event. Nothing on the historical part of the chart ever fired one, and no setting changes that. The full behaviour, including the frequency constant that defaults to firing intrabar rather than on close, is in running and maintaining a strategy.

It is not a trading plan

A strategy() script contains entries, exits and sizing. A trading plan also contains the parts that never become code: how much of your capital this idea gets, what you do when it is in drawdown, when you would abandon it, and what else you are running alongside it.

The script cannot hold those, and a backtest cannot test them. This is why a strategy with a good equity curve and no plan around it still fails — not because the code was wrong.

It is not evidence on its own

A strategy() script that compiles, runs and reports a profit has demonstrated that the emulator, under its assumptions, on this slice of history, with these parameters, produced this curve. Each clause in that sentence is a qualification:

ClauseWhy it limits the claim
the emulator's assumptionsintrabar order is inferred, gaps are treated as empty [1]
this slice of historyhow much you get depends on your account plan [6]
these parametersif you tried ten sets, the best is a biased estimate
this instrumentslippage is in ticks, and a tick is not the same size elsewhere

None of that makes backtesting useless. It makes a backtest a filter rather than a forecast: it can tell you an idea is broken, and it cannot tell you an idea is good.

So what is it good for?

Specifying an idea precisely enough that it can be wrong. That sounds modest and is the entire value. A rule you can state, test and audit is one you can improve; a discretionary feel is one you can only argue about.



Tactix AI — Studio vs Guide

Tactix AI is AlfaTactix’s product assistant brand (open Tactix AI).

  • Tactix Studio turns a one-sentence strategy description into a draft across Timeframe, Signals, Filters, and Risk in the visual Strategy Builder. You review and edit every field before Code Generator writes MQL5 or Pine Script.
  • Tactix Guide explains the step you are on — what to fill, what a control means, or how to phrase a rule — without dumping untested source code.

That is form-first automation: the LLM never replaces Code Generator, and you keep plan limits and real-time validation.

Frequently Asked Questions

A strategy is a Pine Script that calls strategy() so TradingView can simulate orders, equity, and a Strategy Tester report. Official overview: Pine strategies [1]. It is not the same as an indicator() plot. In AlfaTactix, TradingView Basic export is a v6 strategy file (.pine), not a study-only script. See Build a Pine strategy without coding.

No. TradingView documents that indicators calculate and display; they do not use the broker emulator. Alerts can notify you, but they are not a full backtested strategy. Compare types in the Pine script structure [2] guide, then attach a strategy as in Pine Editor setup.

Backtests and the Strategy Tester run on TradingView’s infrastructure when you open the report. Live broker execution depends on your TradingView plan, broker integration, and whether you use alerts versus connected trading — always check current TradingView help. This is different from an MT5 Expert Advisor that needs a terminal or VPS; see What is an Expert Advisor.

No guarantee. Reviews such as Park and Irwin (2007) in the Journal of Economic Surveys find mixed results for technical trading rules after costs (DOI [3]). Use Tester reports, then paper trading. AlfaTactix does not promise returns.

Use Pine when you work on TradingView charts and want strategy() reports. Use MQL5 when your broker workflow is MetaTrader 5. Sister hub: MQL5 & Expert Advisors. Same visual builder can target either plan — Strategy Builder demo.

Pine Editor → paste → Save → Add to chart. Step-by-step: Pine Editor setup. Official: Where to work in Pine [4].

References

  1. TradingView. Strategies. https://www.tradingview.com/pine-script-docs/concepts/strategies
  2. TradingView. Script structure. https://www.tradingview.com/pine-script-docs/language/script-structure
  3. Park, C.-H., & Irwin, S. H. (2007), Journal of Economic Surveys. What do we know about the profitability of technical analysis?. https://doi.org/10.1111/j.1467-6419.2007.00519.x
  4. TradingView. First steps. https://www.tradingview.com/pine-script-docs/primer/first-steps
  5. TradingView. Alerts. https://www.tradingview.com/pine-script-docs/concepts/alerts
  6. TradingView. Limitations. https://www.tradingview.com/pine-script-docs/writing/limitations