Conversion Rules
Conversion rules are essential for transforming numerical output data from one rule into a specific type of input required by another. The Arconomy rules engine uses strongly typed values for currency amounts, quote prices, pip values and volume quantities. Each of these types carries associated metadata such as a currency code, a symbol and the correct decimal precision. When a rule that performs calculations — such as the Simple Calculator — produces a generic numeric value, it must be converted to the correct type before it can be used as input by a rule that requires a strongly typed value.
Why Conversion Matters
Rules that perform calculations on various types of numerical data produce a generic numeric value. If this value is then required as an input by a rule that expects a strongly typed input — such as a quote price for a Stop Loss rule — the generic number will need to be converted to that type first. This is what the conversion rules are used for.
Conversion rules enforce type safety within the rules engine. Without them, you would not be able to pass calculated values to rules that require specific data types. They ensure that every value flowing through your strategy carries the correct metadata — the right symbol, currency code and decimal precision — so that downstream rules can interpret and use the data correctly.
Convert to Price
The Convert to Price rule converts a decimal number into a properly typed quote price for a specific financial instrument. Once configured with a symbol, the rule outputs a quote price value with the correct decimal precision for that instrument.
This is one of the most commonly used conversion rules. Whenever you calculate a price level using a calculator rule or other arithmetic, you need to convert the result to a quote price before it can be used as a price input for rules such as Stop Loss, Take Profit or Place Trades.
Example: Dynamic Stop Loss from Spread
To set a dynamic stop loss price for a buy position by subtracting 10 times the current spread:
- Add a Simple Calculator rule. Configure it to take the spread from the latest tick data value, multiply it by ten, then subtract that value from the current bid price.
- The calculator outputs a generic number — not yet a properly typed quote price.
- Add a Convert to Price rule. Connect an execution link and a data dependency from the calculator output to this conversion rule. Configure it with the correct symbol (for example, Gold against the US dollar).
- The conversion rule now outputs a properly typed quote price with the correct decimal precision.
- Configure the Stop Loss rule and select the Convert to Price rule as the source for the stop loss price input.
See the Convert to Price rule page for full details on all input parameters and output values.
Convert to Pips
The Convert to Pips rule converts a decimal number into a pip value for a specific financial instrument. This is used whenever you need to pass a calculated number as a pip input to another rule — for example, setting a stop loss distance in pips or a take profit distance based on a calculated value.
Pip values carry the correct precision and symbol metadata, ensuring that the receiving rule interprets the distance correctly regardless of the instrument being traded.
See the Convert to Pips rule page for full details on all input parameters and output values.
Convert to Currency
The Convert to Currency rule converts a numeric value into a currency amount with the appropriate currency code and precision. This is used when you need to pass a calculated amount as a currency input to another rule — for example, setting a risk amount or a monetary threshold.
The Convert to Currency rule has an additional feature that allows you to exchange one currency amount into another currency. This makes it useful not only for type conversion but also for currency exchange calculations within your strategy.
See the Convert to Currency rule page for full details on all input parameters, output values and the currency exchange feature.
Convert to Quantity
The Convert to Quantity rule converts a decimal number into a properly formatted volume quantity for a specific financial instrument. This is used when you need to pass a calculated lot size or volume as a quantity input to a trade execution rule such as Place Trades.
The output carries the correct precision and rounding for the configured instrument, ensuring that the trade size conforms to the broker's lot size requirements.
See the Convert to Quantity rule page for full details on all input parameters and output values.
Convert to Number
The Convert to Number rule performs the reverse operation — it converts a strongly typed value (such as a price, pip value, currency amount or quantity) back into a standard decimal number. This is useful when you need to use a typed value in a calculation rule that expects a generic numeric input.
See the Convert to Number rule page for full details on all input parameters and output values.
Finding the Right Input Source
If you cannot see the output field you are looking for in a rule's input data options, first check that you are selecting the correct source option:
- From Strategy Configuration — available when there are strategy configuration values of the required type. Select this to use the static values that will be passed in for different strategy configurations.
- From Data Source — displays data source rules such as Price Data.
- From State — displays the three state rules: Strategy State, Account State and Trade State.
- From Rule — displays all other valid rules whose output types match the required input. If you cannot see the rule or field you are looking for, make sure the rule is valid and the field has been explicitly converted to the correct type using the appropriate conversion rule.
Conversion rules play a key role in the flow of data through the rules engine by enforcing type safety. If a calculated value does not appear as an available input for another rule, it is likely because the value needs to be converted to the correct type first.
Was this helpful? Let us know