Simple Calculator

The Simple Calculator rule lets you perform mathematical calculations using configurable arithmetic expressions with multiple input variables. Define your own formulas to compute derived values that can be used throughout your strategy, with full control over rounding behaviour and decimal precision.

How It Works

The Simple Calculator evaluates a user-defined arithmetic expression that can reference one or more input variables. You write the expression using standard mathematical notation with support for addition (+), subtraction (-), multiplication (*), division (/), and parentheses for grouping. Variables are defined as named inputs that receive values from other rules on the canvas, allowing your formula to react dynamically to changing market conditions.

After the expression is evaluated, the result is rounded according to your chosen rounding mode: Floor (always rounds down), Ceiling (always rounds up), or Half Up (standard rounding where 0.5 rounds up). You also specify the number of decimal places for the output, ensuring the calculated value meets your precision requirements. An optional absolute value setting converts any negative result to its positive equivalent.

Inputs

Input Type Required Description
Variables List No A list of named variables that can be referenced in the expression. Each variable receives its value from a connected rule output on the canvas.
Expression String Yes The arithmetic expression to evaluate. Supports +, -, *, /, and parentheses. Reference variables by their defined names.
Rounding Selection Yes The rounding method applied to the result. Options: Floor (round down), Ceiling (round up), Half Up (standard rounding). Default: Half Up.
Decimal Places Number Yes The number of decimal places to include in the output value.
Absolute Result Boolean No When enabled, the output is converted to its absolute (non-negative) value. Default: false.

Outputs

Output Type Description
Value Number The result of the evaluated expression, rounded and formatted according to the configured rounding mode and decimal places.

Tips

Use the Simple Calculator to create custom risk calculations, such as computing position size from account balance, risk percentage, and stop-loss distance. Group operations with parentheses to ensure correct order of evaluation. When working with currency values, set the rounding mode to Floor and specify the appropriate number of decimal places for your instrument to avoid over-allocation.

Was this helpful? Let us know