Currency codes such as currency.USD, currency.EUR and currency.BTC, for strategy() and request.* currency arguments, plus currency.NONE.
currency.* constants are strings holding the ISO code, such as "USD" for currency.USD. They go in the currency argument of strategy(), request.security and the other request.* functions, where the result is converted to that currency at the exchange rate of each bar. They also compare against syminfo.currency, the quote currency of the chart's symbol, and syminfo.basecurrency.
currency.NONE means no currency. Pass it to leave a request unconverted, for values that are not money, such as a ratio.
Constants
| Name | Value | Description |
|---|---|---|
currency.NONE | No currency; leaves a currency setting unset. | |
currency.AED | AED | UAE dirham |
currency.ARS | ARS | Argentine peso |
currency.AUD | AUD | Australian dollar |
currency.BDT | BDT | Bangladeshi taka |
currency.BHD | BHD | Bahraini dinar |
currency.BRL | BRL | Brazilian real |
currency.BTC | BTC | Bitcoin |
currency.CAD | CAD | Canadian dollar |
currency.CHF | CHF | Swiss franc |
currency.CLP | CLP | Chilean peso |
currency.CNY | CNY | Chinese yuan |
currency.COP | COP | Colombian peso |
currency.CZK | CZK | Czech koruna |
currency.DKK | DKK | Danish krone |
currency.EGP | EGP | Egyptian pound |
currency.ETH | ETH | Ether |
currency.EUR | EUR | Euro |
currency.GBP | GBP | British pound |
currency.HKD | HKD | Hong Kong dollar |
currency.HUF | HUF | Hungarian forint |
currency.IDR | IDR | Indonesian rupiah |
currency.ILS | ILS | Israeli shekel |
currency.INR | INR | Indian rupee |
currency.ISK | ISK | Icelandic krona |
currency.JPY | JPY | Japanese yen |
currency.KES | KES | Kenyan shilling |
currency.KRW | KRW | South Korean won |
currency.KWD | KWD | Kuwaiti dinar |
currency.LKR | LKR | Sri Lankan rupee |
currency.MAD | MAD | Moroccan dirham |
currency.MXN | MXN | Mexican peso |
currency.MYR | MYR | Malaysian ringgit |
currency.NGN | NGN | Nigerian naira |
currency.NOK | NOK | Norwegian krone |
currency.NZD | NZD | New Zealand dollar |
currency.PEN | PEN | Peruvian sol |
currency.PHP | PHP | Philippine peso |
currency.PKR | PKR | Pakistani rupee |
currency.PLN | PLN | Polish zloty |
currency.QAR | QAR | Qatari riyal |
currency.RON | RON | Romanian leu |
currency.RSD | RSD | Serbian dinar |
currency.RUB | RUB | Russian ruble |
currency.SAR | SAR | Saudi riyal |
currency.SEK | SEK | Swedish krona |
currency.SGD | SGD | Singapore dollar |
currency.THB | THB | Thai baht |
currency.TND | TND | Tunisian dinar |
currency.TRY | TRY | Turkish lira |
currency.TWD | TWD | New Taiwan dollar |
currency.USD | USD | US dollar |
currency.USDT | USDT | Tether |
currency.VES | VES | Venezuelan bolivar |
currency.VND | VND | Vietnamese dong |
currency.ZAR | ZAR | South African rand |
Remarks
- Conversion uses the rate at the time of each bar, not today's rate.
- Crypto codes such as currency.BTC, currency.ETH and currency.USDT convert to a coin, which is useful for pricing a stock in bitcoin.
Example
//@version=6
strategy("Currency", overlay = true, currency = currency.USD)
inUsd = syminfo.currency == currency.USD
bgcolor(inUsd ? na : color.new(color.orange, 85))
plot(close, "Close", color.gray)
if barstate.islast
label.new(bar_index, high, "Quote currency: " + syminfo.currency)See also
Runs on Sidechair