Why a strategy is different from an indicator
An indicator is a passive computation — it plots lines and shapes on the chart. A strategy is an indicator that can additionally simulate orders. The strategy tester tab in TradingView is the result: it runs your logic against historical bars and reports profit, drawdown, and trade-by-trade detail.
Declaring a strategy
//@version=5
strategy("My first strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
default_qty_type and default_qty_value control how each entry sizes itself if you do not specify a quantity at order time.
Indicator → strategy migration
Take the SMA cross indicator from Part 1. The only change is the first line — indicator becomes strategy:
//@version=5
strategy("SMA cross", overlay=true)
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
plot(fast, color=color.blue)
plot(slow, color=color.orange)
This still plots the lines, but now you can add strategy.entry calls and the strategy tester will start counting trades.
Strategy constraints
A strategy cannot call indicator()-only functions, and it cannot use certain study-only inputs. Most indicator code can be pasted into a strategy with minimal changes.
Backtest tab
Click Strategy Tester at the bottom of the chart. You will see the Overview (net profit, drawdown, win rate), the Performance Summary, and the List of Trades. These three views are how you evaluate the strategy.
What comes next
The next lessons cover the actual entry and exit calls, then how to interpret the numbers the tester reports.