Requests the exchange rate from one currency to another as a series.
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
request.currency_rate(from: series string, to: series string, ignore_invalid_currency: series bool (optional)) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| from | series string | required | Currency code to convert from, such as "EUR". |
| to | series string | required | Currency code to convert to, such as "USD". |
| ignore_invalid_currency | series bool | false | When 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
//@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