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.


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.


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.


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 several properties, such as the target rate, target size, managed stop loss, managed take profit, and so on.

Formulas may use indicators and trading engine properties. The main difference between writing a formula and writing a condition is that while conditions must evaluate to true or false, formulas must evaluate to a number.

A simple math example:

This simple formula may be used to define an initial take profit target 3% above the rate at which the position was taken.

tradingEngine.current.position.entryTargetRate.value * 1.03

A simple JavaScript example:

A bit of very basic JavaScript, introducing conditional statements, allows more intelligence. For example, in this case, we ask if the proposed formula results in a number greater than the current stop loss value; if it does, then the proposed formula is used; if not, then the current stop loss value is left as is.

This is—basically—a trailing stop loss 2% below the moving average that may go higher if the moving average goes up, but it may never come down—thanks to the use of the IF ELSE clause.

if (chart.at01hs.bollingerBand.movingAverage * 0.98 > tradingEngine.current.position.stopLoss.value) 
   {chart.at01hs.bollingerBand.movingAverage * 0.98} 

For developers:

To build more complex logic within a formula, create a function that implements the logic and returns a numerical value, and then call the function:

function orderRate() {
    const ORDER_STEP_NUMBER = 1    // Secuential step number, starting with 1 from the closest to the price.
    const BUY_SELL_SIGN = -1       // 1 for buy orders, -1 for sell orders.
    const STEP_SEPARATION = 0.15   // % of separation of stair steps between them.
    const BASE_FACTOR = 0.2        // % above or below bollinger band without bias.
    const BIAS_FACTOR = 0.3        // % to move the whole stair of orders up or down depending on the bias.
    const BAND_RATE = chart.at01min.bollingerBand.lowerBand    //  Upper Bollinger Band for sell orders, and Lower for buy orders.

    let inbalance = tradingEngine.current.episode.episodeBaseAsset.beginBalance.value - tradingEngine.current.episode.episodeBaseAsset.balance.value

    let BIAS_SIGN

    if (inbalance === 0) {
        BIAS_SIGN = 0
    if (inbalance < 0) {
        BIAS_SIGN = + 1
    if (inbalance > 0) {
        BIAS_SIGN = - 1


    return rate


Click to learn more about formulas

Adding a Formula Node

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