If Else

The If Else rule evaluates a logic statement and outputs different numeric values based on whether the condition is true or false. It provides conditional branching within your strategy, allowing you to dynamically choose between different values for position sizing, price levels, risk parameters, or any other numeric setting based on the current state of your strategy.

How It Works

The If Else rule evaluates a logical statement and outputs a value based on the result. When the logic statement evaluates to true, the rule outputs the True Value. When the statement evaluates to false, the behaviour depends on the Or Else setting.

If Or Else is enabled, the rule outputs the False Value when the logic statement is false. If Or Else is disabled, the rule only produces an output when the logic statement is true — no value is output when the condition is false. This gives you flexibility to create conditional logic flows where an action should only occur under certain conditions, or to provide alternative values for both outcomes.

The logic statement can combine multiple conditions using various logical operators and dependencies. It can evaluate relationships between different rules, data sources, or state variables to determine the execution path. This makes the If Else rule ideal for creating decision points in strategies, such as conditional position sizing based on market conditions, selective execution of different rule paths based on technical indicators, or dynamic parameter selection based on account metrics.

The rule also outputs a boolean result indicating whether the logic statement evaluated to true or false, which can be consumed by subsequent rules for further decision-making.

Inputs

Parameter Description Required Default
Logic Statement The logical expression to evaluate. This can combine multiple conditions and dependencies in a complex expression, referencing outputs from other rules in your strategy. Yes
True Value The numeric value to output when the logic statement evaluates to true. Yes
Or Else Determines whether a False Value should be output when the logic statement is false. When enabled, the False Value input becomes available. Yes
False Value The numeric value to output when the logic statement evaluates to false. Only available when Or Else is enabled. No

Outputs

Output Description
Output Value The value output based on the logic statement evaluation. This will be the True Value if the statement is true, or the False Value if the statement is false and Or Else is enabled.
Result A boolean value indicating whether the logic statement evaluated to true or false. This can be passed to other rules for additional conditional logic.

Tips

Use If Else for dynamic position sizing by setting the True Value to a larger lot size during favourable market conditions and the False Value to a smaller lot size when conditions are less certain. You can chain multiple If Else rules together by feeding the Result output of one into the Logic Statement of another to create multi-layered decision trees.

Was this helpful? Let us know