Creating your own indicator in TradingView is a powerful way to test ideas, see custom signals on charts, or share tools with other traders. In this guide I’ll explain, in simple English, what an indicator is, how Pine Script works, and give you a clear step-by-step to build and add an indicator to a chart. I’ll also point to helpful resources so you can learn more. (Images above show a sample Pine Script editor and how an indicator looks on a chart.)
What is an indicator and what is Pine Script?
An indicator is a small program that calculates values from historical price data (like moving averages, RSI, MACD) and shows lines, histograms, or symbols on your chart. Indicators help you spot trends, strength, momentum, and possible turning points.
TradingView uses its own scripting language called Pine Script to write indicators. Pine Script is made for traders: it’s compact, built to work with price series, and is continuously updated by TradingView. The official TradingView docs and quickstart pages show how to open the Pine Editor and create your first indicator. (TradingView)
Quick overview: the typical workflow
Before we start coding, here’s the usual flow when making an indicator:
-
Decide what your indicator should do (e.g., plot an EMA, detect divergence, show buy/sell dots).
-
Open TradingView and go to the Pine Editor.
-
Write a small Pine Script that calculates the indicator values.
-
Save and click Add to Chart so you can see the output.
-
Tweak inputs, colors, and conditions until it matches your idea.
The TradingView docs and community tutorials walk through those exact steps for beginners. (TradingView)
Step 1 — Plan the indicator (keep it simple)
Write a 1–2 sentence description of what you want. Example ideas:
-
“Plot a 20-period Exponential Moving Average (EMA) on price.”
-
“Show a histogram of the difference between two EMAs (a MACD-like line).”
-
“Display a colored background when RSI is above 70 or below 30.”
Start with something simple. If your idea is complex, break it into smaller pieces and build the pieces first. Many tutorials emphasize starting with a small, working sample and extending it. (Medium)
Step 2 — Open Pine Editor and start a new indicator
-
Log in to TradingView and open a chart.
-
At the bottom of the page, click the Pine Editor tab.
-
Use the editor’s Open / New menu and choose “New blank indicator” (or “Create new/Indicator”).
-
The editor will show a small template. Replace that with your code. The official primer gives a standard “first indicator” example to copy and experiment with. (TradingView)
Step 3 — The smallest possible indicator (example)
Below is a minimal indicator you can paste into Pine Editor to see how things work:
//@version=5
indicator("My Simple EMA", overlay=true)
length = input.int(20, title="EMA Length")
ema_val = ta.ema(close, length)
plot(ema_val, title="EMA", linewidth=2)
Explanation in plain language:
-
//@version=5tells TradingView which Pine version to use. -
indicator("My Simple EMA", overlay=true)creates an indicator named “My Simple EMA” and sets it to draw on the price chart (overlay=true). -
input.int(20, ...)lets the user change the EMA length from the indicator settings. -
ta.ema(close, length)computes the EMA value from thecloseprice series. -
plot(...)draws the line on the chart.
This tiny script demonstrates the basic structure of most indicators: declare the script, accept inputs, compute values and plot them. The Pine primer and quickstart give similar examples. (TradingView)
Step 4 — Save and add to chart
When your code is in the editor:
-
Click Save, give the script a name.
-
Click Add to Chart (button at the bottom of the Pine Editor).
-
If the script has errors, TradingView will show them and point to line numbers — fix those, save again, and add to chart.
The “Add to Chart” step is how you test and visually confirm your indicator. Guides and community tutorials show this exact flow. (TradingView)
Step 5 — Make it user-friendly
Add inputs so other users (or you later) can adjust parameters without editing code:
-
input.int(...)for integer settings (lengths, periods). -
input.float(...)for decimal numbers. -
input.color(...)for color choices. -
input.bool(...)for on/off toggles.
Example: give the EMA a color and thickness input:
col = input.color(color.blue, title="Line Color")
w = input.int(2, title="Line Width")
plot(ema_val, color=col, linewidth=w)
Also add comments in the code using // to explain sections. This helps when you return to the script later or share it. Community tutorials stress the benefit of clean, documented code. (Medium)
Step 6 — Add signals or drawings (optional)
If you want buy/sell signals, you can add shapes or background colors:
-
plotshape(condition, style=shape.triangleup, location=location.belowbar)draws an arrow whenconditionis true. -
bgcolor(condition ? color.new(color.green, 85) : na)colors the chart background when aconditionmatches.
Remember: signals are only as good as your logic and testing. Many community guides show examples of plotting signals and testing them visually. (algotrading101.com)
Step 7 — Test and iterate
-
View different timeframes and symbols.
-
Use the indicator’s inputs to test sensitivity.
-
If you have a TradingView Strategy (not just an indicator), you can run the Strategy Tester to see hypothetical results — but strategy code uses
strategy()instead ofindicator().
Start with visual/manual checks, then move to more formal testing if you want to quantify performance. Guides and the TradingView community give many examples of iterative testing. (TradingView)
Where to learn more (good resources)
-
TradingView Pine Script documentation / primer — official docs and first-indicator walkthrough. (TradingView)
-
Community tutorials and blogs — they provide examples, templates, and ideas you can copy and adapt. Search for “Pine Script tutorial” or “create indicator TradingView”. (algotrading101.com)
-
Public scripts on TradingView — read other authors’ code to learn patterns and tricks. The public script library is a great learning place. (TradingView)
Final tips and common pitfalls
-
Start small. Build a simple indicator, then add features.
-
Check Pine version. New versions add functions; use
//@version=5or the latest as needed. -
Avoid repainting logic. Some indicators use future data incorrectly; ensure your conditions only use past or current bar data for reliable signals.
-
Document inputs. Clear names help when you or others change settings.
-
Read other people’s code. The best way to learn is by studying working scripts from the community. (TradingView)
Creating indicators in TradingView is approachable even for beginners. With a simple idea, a few lines of Pine Script, and the built-in Pine Editor, you can see your logic plotted on real charts within minutes. Use the official docs and community guides to expand your skills, and always test ideas before relying on them in live trading.