strategy.convert_to_symbol() - Pine Script Function
strategy.convert_to_symbol()
Section titled “strategy.convert_to_symbol()”Overview
Section titled “Overview”Converts the value from the currency used by the strategy (strategy.account_currency) to the currency that the symbol on the chart is traded in (syminfo.currency).
Syntax
Section titled “Syntax”strategy.convert_to_symbol(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”//@version=6strategy("`strategy.convert_to_symbol` Example", currency = currency.EUR)// Calculate the max qty we can buy using current chart's currency.calcContracts(accountMoney) => math.floor(strategy.convert_to_symbol(accountMoney) / syminfo.pointvalue / close)// Return max qty we can buy using 300 eurosqt = calcContracts(300)// Strategy calls to enter long trades every 15 bars and exit long trades every 20 bars using our custom qty.if bar_index % 15 == 0strategy.entry("Long", strategy.long, qty = qt)if bar_index % 20 == 0strategy.close("Long")