Overview: all instrument variables in TradingView's Pine Script
Overview: all instrument variables in TradingView’s Pine Script
Section titled “Overview: all instrument variables in TradingView’s Pine Script”TL;DR
Pine Script exposes instrument metadata via thesyminfo.*namespace—everything from the exchange prefix and tick size to the base/quote currency and trading session.
At a Glance
Section titled “At a Glance”| Difficulty | Beginner |
| Time to implement | 10-15 min |
| Category | Language Basics |
Quick Actions
Section titled “Quick Actions”Quick Start
Section titled “Quick Start”//@version=5indicator("Instrument snapshot", overlay=true, max_labels_count=500)
text = str.format( "{0}\nExchange: {1}\nTick: {2}\nCurrency: {3}\nType: {4}", syminfo.tickerid, syminfo.prefix, str.tostring(syminfo.mintick), syminfo.currency, syminfo.type)
if barstate.islast label.new(bar_index, close, text, style=label.style_label_left, textcolor=color.white, bgcolor=color.new(color.blue, 70))Why It Matters
Section titled “Why It Matters”Scripts that adapt to symbol metadata feel smarter: they can adjust tick-based inputs, change currency formatting, or refuse to run on unsupported asset classes. The syminfo variables remove guesswork—everything you need about the current instrument ships in the runtime.
What You’ll Learn
Section titled “What You’ll Learn”- The complete list of instrument variables, grouped by purpose.
- How to display the metadata on chart for debugging or UX.
- Practical cases for using each group (tick-based sizing, currency-aware formatting, session filters).
- Tips for combining
syminfovalues with other Pine helpers.
Quick Reference
Section titled “Quick Reference”| Category | Variables | Purpose |
|---|---|---|
| Symbol & source | syminfo.prefix, syminfo.root, syminfo.ticker, syminfo.tickerid | Exchange prefix, root symbol, naked ticker, and exchange-qualified ticker. |
| Price increments | syminfo.mintick, syminfo.pointvalue | Tick size and currency value per full point move. |
| Currency | syminfo.currency, syminfo.basecurrency | Quote currency and base currency (pairs). |
| Time | syminfo.timezone, syminfo.session | Exchange time zone and session template (regular vs extended hours). |
| General | syminfo.description, syminfo.type | Human-readable description and asset class (stock, crypto, futures, …). |
Implementation Blueprint
Section titled “Implementation Blueprint”-
Query the
syminfonamespace
Access the variables directly—no imports or requests needed.tickerId = syminfo.tickeridtickSize = syminfo.mintickassetClass = syminfo.type -
Format output for humans
Bundle values into labels, tables, or alerts so users understand what’s driving the script.summary = str.format("{0} ({1})\nTick: {2}\nCurrency: {3}",syminfo.ticker,syminfo.prefix,str.tostring(syminfo.mintick),syminfo.currency) -
Adapt behaviour
Use the metadata to change inputs, skip logic, or align calculations to the instrument.minStopTicks = syminfo.type == "crypto" ? 5 : 1stopPrice = close - syminfo.mintick * minStopTicks
Example Playbook
Section titled “Example Playbook”//@version=5indicator("Instrument-aware template", overlay=true, max_labels_count=500)
// Build a helper that returns the full instrument profile.getInstrumentProfile() => str.format( "{0}\n{1}\nType: {2}\nTick: {3} (point {4})\nCurrency: {5}/{6}\nSession: {7}", syminfo.tickerid, syminfo.description, syminfo.type, str.tostring(syminfo.mintick), str.tostring(syminfo.pointvalue), syminfo.basecurrency, syminfo.currency, syminfo.session )
// Choose risk settings based on min tick.minStopTicks = syminfo.mintick <= 0.01 ? 5 : 1stopLevel = close - syminfo.mintick * minStopTicksplot(stopLevel, "Adaptive stop hint", color=color.new(color.red, 0))
if barstate.islast label.new(bar_index, close, getInstrumentProfile(), style=label.style_label_left, textcolor=color.white, bgcolor=color.new(color.blue, 65))- Metadata prints directly on chart, helping you validate which contract, session, and currency your script sees.
- Tick-size aware logic keeps risk calculations sensible across asset classes.
- The helper encapsulates repeated formatting so you can reuse it in alerts or dashboards.
Pro Tips & Pitfalls
Section titled “Pro Tips & Pitfalls”- Futures contracts roll—use
syminfo.rootwhen you need the continuous symbol rather than the dated contract. - Combine
syminfo.sessionwithsession.ismarket()to enforce regular-hours-only trading. syminfo.pointvaluehelps convert point-based stops to currency risk; multiply by contract size if needed.- Cache heavy string formatting in a
varand refresh whenbarstate.islastto avoid performance penalties.
Troubleshooting & FAQ
Section titled “Troubleshooting & FAQ”Why does syminfo.basecurrency return na?
Section titled “Why does syminfo.basecurrency return na?”It only applies to currency pairs and crypto symbols quoted with base/quote conventions. Stocks and indices return na.
syminfo.session looks cryptic—how do I use it?
Section titled “syminfo.session looks cryptic—how do I use it?”It returns TradingView’s session template (e.g., 24x7, 0930-1600). Use it with session.ismarket() or compare against custom strings to detect extended hours.
Can I detect contract size or margin requirements?
Section titled “Can I detect contract size or margin requirements?”Pine doesn’t expose contract multipliers directly. Combine syminfo.pointvalue with exchange documentation or strategy(position_size) to infer the effect.
Key Takeaways
Section titled “Key Takeaways”syminfo.*variables give you the full instrument profile—symbol, exchange, currencies, tick size, session, and more.- Display the information for debugging and UX, then use it to adapt sizing, formatting, or eligibility rules.
- Cache or throttle label/table updates since the metadata rarely changes mid-chart.
- Mastering these helpers makes your scripts portable across asset classes without hard-coded assumptions.
Keep Going
Section titled “Keep Going”- Open AI Editor to apply the pattern with guided assistance
- Browse PineScript Examples for ready-to-run templates
- Connect to Live Trading when you are ready to automate
Adapted from tradingcode.net, optimised for Algo Trade Analytics users.