Sidechair

strategy.convert_to_account()

Browse the reference

Converts an amount from the symbol's currency into the strategy's account currency.

Try it in the editor

strategy.convert_to_account(value) multiplies value by the exchange rate between the symbol's currency (syminfo.currency) and the account currency set by the currency parameter of strategy(). When the two currencies are the same, it returns value unchanged.

Use it when a figure computed from prices, such as a stop distance times a size, has to be compared with equity or profit, which are always in the account currency.

Syntax

Pine Script
strategy.convert_to_account(value: series int/float) -> series float

Arguments

NameTypeDefaultDescription
valueseries int/floatrequiredAn amount in the symbol's currency to convert.

Returns

series float: The amount expressed in the strategy's account currency.

Remarks

  • The conversion uses the exchange rate of the current bar, so the result can differ from bar to bar when the currencies differ.
  • strategy.convert_to_symbol does the opposite conversion.

Examples

Pine ScriptRisk of one share in account currencyOpen in editor
//@version=6
strategy("Risk per share", overlay = false, currency = currency.EUR)
stopDist = ta.atr(14) * 2
plot(strategy.convert_to_account(stopDist), "Risk per share (EUR)", color.red)
Pine ScriptCurrencies in playOpen in editor
//@version=6
strategy("Currencies", overlay = true)
if barstate.islast
    label.new(bar_index, high, "Symbol currency: " + syminfo.currency, style = label.style_label_down)
plot(close, "Close", color.gray)

See also

Runs on Sidechair