Pine Script Plot Text: A Comprehensive Guide
So you want to add text to your TradingView charts? I get it - sometimes you need to show more than just lines and shapes. Maybe you want to label important price levels, show when your strategy triggers, or just add some notes to your chart. Let me walk you through how to do this in Pine Script.
The Different Ways to Show Text
Pine Script gives you a few different tools for putting text on your charts. Each one works a bit differently, so let's break them down:
Using plotchar() - The Simple One
This is probably the easiest way to get started. Here's how it works:
//@version=5
indicator("My Text Indicator")
plotchar(true, title="Price", text="Current Price", char="", location=location.top)
A few things to know about plotchar():
- You can show text using the
textparameter - If you want just one character, use the
charparameter instead - The text has to be fixed - you can't make it change based on price or other values
- If you only want text (no character), just set
charto empty quotes like""
Using plotshape() - More Flexible
This one's my favorite because you get more control:
//@version=5
indicator("Shape with Text")
plotshape(true, title="Signal", text="BUY", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white)
What's cool about plotshape():
- You can add shapes behind your text (or skip them entirely)
- Control where the text appears (above or below bars)
- Change text color with
textcolor - Hide the shape by setting
colortona
Showing Multiple Lines of Text
Want to stack text on top of each other? Here's a little trick:
//@version=5
indicator("Stacked Text")
plotshape(true, text="Line 1\nLine 2", style=shape.labelup, location=location.belowbar, color=na, textcolor=color.white)
See that weird character after \n? That's a special invisible character that helps Pine Script understand you want a new line. It's a bit quirky, but it works.
When These Methods Fall Short
Here's the thing - both plotchar() and plotshape() have some limitations that might frustrate you:
- You can't show changing values (like the current price)
- They show up on every single bar where your condition is true
- You don't get much control over how they look
If you need something more flexible, you'll want to look into using label.new() instead. Labels can:
- Show actual price values and other changing data
- Be placed exactly where you want them
- Look however you want them to look
- You can have up to 500 of them on your chart
Some Tips That Actually Help
After working with Pine Script text for a while, here's what I've learned:
Pick the right tool for the job:
- Need simple, static text? Use plotchar() or plotshape()
- Need to show changing values or want more control? Go with labels
Make it readable:
- Think about where you place your text so it doesn't cover important chart data
- Pick colors that actually show up against your chart background
- Don't go crazy with the size - bigger isn't always better
Keep it clean:
- Only show text when it's actually useful
- Too much text makes your chart look messy
- Consider whether the information really needs to be on the chart or if it could go somewhere else
Let's See Some Real Examples
Marking High Points
//@version=5
indicator("Price Label")
isHighPrice = high == highest(high, 10)
plotshape(isHighPrice, text="High", style=shape.labeldown, location=location.abovebar, color=na, textcolor=color.green)
This will put "High" above any bar that's the highest in the last 10 bars.
Showing Multiple Indicators
//@version=5
indicator("Stacked Info")
rsi = rsi(close, 14)
rsiText = "RSI: " + str.tostring(rsi, "#.##")
macdText = "MACD: " + str.tostring(macd(close, 12, 26, 9)[^0], "#.##")
plotshape(true, text=rsiText + "\n" + macdText, style=shape.square, location=location.bottom, color=na, textcolor=color.white)
This shows both RSI and MACD values stacked on top of each other.
No-Code Alternative
Look, I'll be honest - writing Pine Script can be a pain sometimes. If you're not into coding but still want to add text and other elements to your charts, there are visual tools out there that can help. Pineify is one that lets you edit elements without writing any code. It's pretty handy if you just want to get things done without dealing with syntax errors.
You can add text, shapes, lines, and all sorts of chart elements through a visual interface. Plus you can tweak settings right on the chart instead of going back to edit code every time you want to change something.
Website: Pineify
Check out what Pineify can do.Wrapping Up
Adding text to your Pine Script indicators isn't rocket science, but it does take some practice to get right. Start with the simple functions like plotchar() and plotshape(), then move on to labels when you need more power.
The key is to keep it useful and readable. Your future self (and anyone else looking at your charts) will thank you for not cluttering things up with unnecessary text everywhere.
Give these examples a try, tweak them to fit your needs, and don't be afraid to experiment. That's how you really learn this stuff.
