In this article, we will delve into the syminfo.basecurrency
function, exploring its functionality, syntax, and practical applications.
What is syminfo.basecurrency
?
Definition and Purpose
syminfo.basecurrency
is a built-in variable in Pine Script that returns a string representing the base currency of the currently selected trading pair. In any financial market, a trading pair consists of two parts: the base currency and the quote currency. For instance, in the pair EUR/USD
, EUR is the base currency and USD is the quote currency.
Importance in Trading Scripts
Understanding the base currency is crucial in financial analysis and trading scripts for several reasons:
- Currency Conversion: When dealing with multi-currency portfolios, knowing the base currency is essential for accurate conversion and valuation.
- Strategy Customization: Trading strategies might vary based on the base currency, especially in Forex markets.
- Risk Management: Knowing the base currency aids in better risk assessment and management.
Syntax and Usage
Basic Syntax
The basic syntax of syminfo.basecurrency
is straightforward:
string baseCurrency = syminfo.basecurrency
Here, baseCurrency
is a variable that stores the base currency of the current symbol.
Example
Let’s consider a practical example where we print the base currency on the chart:
//@version=5 indicator("Base Currency Display", overlay=true) string baseCurr = syminfo.basecurrency label.new(bar_index, high, text="Base Currency: " + baseCurr, style=label.style_labeldown)

In this script:
- We create an indicator that displays the base currency.
baseCurr
holds the base currency of the symbol.- A label is created on the chart showing the base currency.
Walkthrough of the Code
string baseCurr = syminfo.basecurrency
: This line initializes a string variablebaseCurr
and assigns it the value of the base currency of the current trading pair.label.new(bar_index, high, text="Base Currency: " + baseCurr, style=label.style_labeldown)
: This line creates a new label on the chart. It is positioned at the current bar index and the highest price of the current bar. The label displays the text “Base Currency: ” followed by the base currency value.
Key Features and Takeaways
- Functionality:
syminfo.basecurrency
retrieves the base currency of the current trading pair. - Use Cases: Essential for multi-currency analysis, strategy customization, and risk management.
- Ease of Use: Simple syntax, easily integrated into various trading scripts.
- Practical Application: Can be used to display currency information on charts, in alerts, or as part of a larger trading strategy.
In conclusion, syminfo.basecurrency
is a valuable tool in Pine Script for any financial programmer or trader looking to deepen their market analysis and strategy development. By providing easy access to the base currency of a trading pair, it opens up a range of possibilities for dynamic and responsive trading scripts.