strategy.convert_to_account() - Pine Script Function
strategy.convert_to_account()
Section titled “strategy.convert_to_account()”Overview
Section titled “Overview”Converts the value from the currency that the symbol on the chart is traded in (syminfo.currency) to the currency used by the strategy (strategy.account_currency).
Syntax
Section titled “Syntax”strategy.convert_to_account(value) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| value | series int/float | The value to be converted. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”// Calculates the "Buy and hold return" using your account's currency.//@version=6strategy("`strategy.convert_to_account` Example 2", currency = currency.EUR)dateInput = input.time(timestamp("20 Jul 2021 00:00 +0300"), "From Date", confirm = true)buyAndHoldReturnPct(fromDate) =>if time >= fromDate money = close * syminfo.pointvalue var initialBal =strategy.convert_to_account(money) (strategy.convert_to_account(money) - initialBal) / initialBal * 100plot(buyAndHoldReturnPct(dateInput))