Skip to content

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 the syminfo.* namespace—everything from the exchange prefix and tick size to the base/quote currency and trading session.

DifficultyBeginner
Time to implement10-15 min
CategoryLanguage Basics
//@version=5
indicator("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))
Tip. Instrument metadata is static—cache the label on the last historical bar or when inputs change so you don’t create hundreds of labels unnecessarily.

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.

  • 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 syminfo values with other Pine helpers.
CategoryVariablesPurpose
Symbol & sourcesyminfo.prefix, syminfo.root, syminfo.ticker, syminfo.tickeridExchange prefix, root symbol, naked ticker, and exchange-qualified ticker.
Price incrementssyminfo.mintick, syminfo.pointvalueTick size and currency value per full point move.
Currencysyminfo.currency, syminfo.basecurrencyQuote currency and base currency (pairs).
Timesyminfo.timezone, syminfo.sessionExchange time zone and session template (regular vs extended hours).
Generalsyminfo.description, syminfo.typeHuman-readable description and asset class (stock, crypto, futures, …).
  1. Query the syminfo namespace
    Access the variables directly—no imports or requests needed.

    tickerId = syminfo.tickerid
    tickSize = syminfo.mintick
    assetClass = syminfo.type
  2. 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
    )
  3. Adapt behaviour
    Use the metadata to change inputs, skip logic, or align calculations to the instrument.

    minStopTicks = syminfo.type == "crypto" ? 5 : 1
    stopPrice = close - syminfo.mintick * minStopTicks
//@version=5
indicator("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 : 1
stopLevel = close - syminfo.mintick * minStopTicks
plot(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))
Why this works.
  • 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.
  • Futures contracts roll—use syminfo.root when you need the continuous symbol rather than the dated contract.
  • Combine syminfo.session with session.ismarket() to enforce regular-hours-only trading.
  • syminfo.pointvalue helps convert point-based stops to currency risk; multiply by contract size if needed.
  • Cache heavy string formatting in a var and refresh when barstate.islast to avoid performance penalties.

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.

  • 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.

Adapted from tradingcode.net, optimised for Algo Trade Analytics users.