Situations and conditions are used to define the specific market situations in which a certain event should be triggered. Formulas are used to dynamically determine the value of targets.

Situation

A situation refers to a specific state of the market in which a certain event should take place, as defined by any number of conditions.

In other words, you define situations in which you wish a certain event to happen (i.e.: trigger on the strategy, take a position, etc.) and each situation is described as a set of conditions that need to be met for the event to be triggered.

A situation gets validated when all conditions under it are true.

An event may have more than one situation attached to it. In such a case, when any of the situations gets validated, the event gets triggered. That is, events may be triggered in different circumstances, meaning that you are free to define different situations upon which the same event would be triggered. In such a case, when any of the situations evaluate true, then the event is triggered.

Click to learn more about situations

Adding a Situation Node

To add a situation, select Add Situation on the corresponding event node menu. A situation is added along with a condition and JavaScript code node.

Condition

Conditions are rules within a situation. When all conditions under a situation validate true, then the situation gets validated as well, and the associated event is triggered.

Therefore, conditions are used to mathematically describe what needs to happen with the market for a certain action to be taken.

For example:

Situation 1

  • Condition A: chart.at01hs.candle.close > chart.at01hs.bollingerBand.MovingAverage → This means that the latest candle at the 1 hour chart closed above the Bollinger Bands moving average.

  • Condition B: chart.at01hs.candle.previous.max > chart.at01hs.bollingerBand.previous.MovingAverage → This means that the maximum value of the candle before the last one, was higher than the Bollinger Bands moving average.

In the example above, conditions A and B are comparison statements that may evaluate either true or false. In the case both would evaluate true then Situation 1 would be true as well.

Click to learn more about conditions

Adding a Condition Node

To add a condition, select Add Condition on the corresponding situation node menu. A condition with its JavaScript code node is added.

Formula

A formula is a mathematical expression intended to determine a numerical value to be applied dynamically to a certain property.

In the context of a trading system, formulas are used to determine the values for stopLoss, takeProfit, positionRate and positionSize.

Formulas may use internal variables made available by the system. In addition to the ones listed above, other variables such as balanceAssetA and balanceAssetB may be of use.

For example:

  • positionRate - positionRate * 2.5 / 100 → This formula may be used to define an initial stop target 2.5% below the rate at which the position was taken.

Click to learn more about formulas

Adding a Formula Node

To add a formula, select Add Formula on the corresponding parent node menu.