Sidechair

request.currency_rate()

Browse the reference

Requests the exchange rate from one currency to another as a series.

Try it in the editor

request.currency_rate returns how many units of the target currency one unit of the source currency buys, bar by bar. Pass three-letter codes such as "EUR" and "USD".

Multiply a price by the rate to restate it in another currency inside your script.

Syntax

Pine Script
request.currency_rate(from: series string, to: series string, ignore_invalid_currency: series bool (optional)) -> series float

Arguments

NameTypeDefaultDescription
fromseries stringrequiredCurrency code to convert from, such as "EUR".
toseries stringrequiredCurrency code to convert to, such as "USD".
ignore_invalid_currencyseries boolfalseWhen true, an unknown currency code returns na instead of stopping the script.

Returns

series float: the exchange rate, or na for an unknown pair.

Remarks

  • The rate is read for each chart bar's time, so a historical chart uses historical rates.
  • On Sidechair: currency rates are not available yet. The call warns once and returns na.

Example

Pine ScriptPrice in eurosOpen in editor
//@version=6
indicator("Close in EUR", overlay = true)
rate = request.currency_rate("USD", "EUR")
plot(close * rate, "Close (EUR)", color = color.blue)

See also

Not on Sidechair yet