Home » Symbol Information Functions » Understanding Symbol Information in Pine Script

Understanding Symbol Information in Pine Script

Photo of author
Published on

In this article, we’ll explore each built-in variable within the syminfo namespace and how it can be utilized in Pine Script programming.

What is the syminfo Namespace?

The syminfo namespace in Pine Script contains a set of built-in variables that provide specific information about the symbol on the chart where the script is running. These variables are dynamic and update every time the chart’s symbol is changed, ensuring that the script executes with the most current symbol data.

Key Built-in Variables in the syminfo Namespace

  1. Base Currency (syminfo.basecurrency)
    • Description: Represents the base currency of a pair. For instance, in the “BTCUSD” pair, syminfo.basecurrency would return “BTC”.
    • Example Usage: Useful for scripts that need to adjust calculations based on the base currency.
  2. Quote Currency (syminfo.currency)
    • Description: Refers to the quote currency in a pair, like “USD” in “BTCUSD”.
    • Example Usage: Essential for converting values into the quote currency or for comparative analysis across different pairs.
  3. Symbol Description (syminfo.description)
    • Description: Provides a long description of the symbol.
    • Example Usage: Useful for displaying detailed symbol information on charts or reports.
  4. Minimum Tick Size (syminfo.mintick)
    • Description: Indicates the minimum price movement of a symbol, which is crucial for precision in trading strategies.
    • Example Usage: Critical for scripts calculating stop loss, take profit levels, or other price-sensitive strategies.
  5. Point Value (syminfo.pointvalue)
    • Description: Shows the multiple of the underlying asset that determines a contract’s value.
    • Example Usage: Important for calculations in futures contracts or when assessing the overall value at stake in a trade.
  6. Symbol Prefix (syminfo.prefix)
    • Description: The exchange or broker’s identifier, like “NASDAQ” for “AAPL”.
    • Example Usage: Helpful for identifying the trading venue, especially when dealing with symbols listed on multiple exchanges.
  7. Root Ticker (syminfo.root)
    • Description: The ticker’s prefix, mainly used for structured tickers like those of futures.
    • Example Usage: Essential for distinguishing between different contracts or series in futures markets.
  8. Trading Session (syminfo.session)
    • Description: Reflects the session setting on the chart for that symbol.
    • Example Usage: Can be used to adjust strategies based on trading sessions.
  9. Symbol Ticker (syminfo.ticker)
    • Description: The symbol’s name without the exchange part.
    • Example Usage: Central for scripts that need to reference the symbol independently of its exchange.
  10. Ticker ID (syminfo.tickerid)
    • Description: A comprehensive string used mostly as an argument for the request.security() function.
    • Example Usage: Vital for scripts that require detailed symbol identification, including session and prefix information.
  11. Timezone (syminfo.timezone)
    • Description: The timezone in which the symbol is traded.
    • Example Usage: Crucial for time-sensitive strategies or for synchronization with market opening/closing times.
  12. Market Type (syminfo.type)
    • Description: Indicates the market type of the symbol, like “stock”, “futures”, or “forex”.
    • Example Usage: Important for scripts that are tailored to specific market types.

Example

//@version=5
indicator("Crypto Symbol Info Display", shorttitle="CSymInfo", overlay=true)

// Accessing selected syminfo variables
baseCurrency = syminfo.basecurrency
quoteCurrency = syminfo.currency
minTickSize = syminfo.mintick
marketType = syminfo.type

// Condition to check if the market type is Crypto
isCrypto = marketType == "crypto"

// Conditional Display of Information
if isCrypto
    label.new(bar_index, high, 
        text="Base Currency: " + baseCurrency + "\n" +
        "Quote Currency: " + quoteCurrency + "\n" +
        "Min Tick Size: " + str.tostring(minTickSize),
        style=label.style_label_down, color=color.new(color.purple, 0), textcolor=color.white, yloc=yloc.abovebar)
Example

Key Takeaways

  • The syminfo namespace in Pine Script is a dynamic and versatile tool for accessing detailed information about the trading symbol.
  • Each variable within the syminfo namespace serves a specific purpose, ranging from identifying the base and quote currencies to understanding the trading session and market type.
  • Utilizing these variables appropriately can significantly enhance the functionality and precision of trading scripts and strategies in Pine Script.

Leave a Comment