Expression Builder


Read Expression Overview if you have not already before reading this page. Expression Builder is a UI component that you use to build logical expression. Logical expression is used in screener, alert and automated trade to define criteria or condition. Watch the video below to learn how to use expression builder.

Filters and Filter Groups

An expression is built using filters and filter groups. A filter contains one or more criteria which are combined using a logical OR operator such as

MarketCap > 100B OR MarketCap < 100M

A Filter Group combines multiple Filters using AND operator such as

(MarketCap > 100B OR MarketCap < 100M) AND ( LastPrice > 1)

The example above shows two filter groups. The first filter group ((MarketCap > 100B OR MarketCap < 100M)) has two filters and the second filter group ( LastPrice > 1) has one filter.

Adding or Removing Filters

In the expression builder, click the ‘+And Filter’ or ‘+OR’ buttons to add filter group or filter respectively. You can delete them by clicking the cross icon.

Affiliate Programs

Building expression

To build the expression, you must add variables, constants or operators.

  • Adding Indicator Variable

    You will add variable by first selecting the indicator that you want and then configuring it. The text box supports auto-suggest, and thus you can either type some characters and select from suggested list, or simply click on the text box and scroll through all available indicators. We also have a full list of supported indicators published.

    1. Click on the text box. A list of all supported indicators and operators will appear.
    2. If you know the name of the indicators, start typing it and suggestions will appear.
    3. If you do not know the name or the auto-suggestion did not work, then simply scroll through all available indicators and find the one you want..
    4. Once selected, configure indicator dialog will appear.
    5. Provide requested parameters
    6. Click Save
    indicator dialog

Most indicators will have these standard parameters in common.

  • Name Parameter

    This is the variable name that will be used and displayed in the expression. Give a short and meaningful but unique name to your variable. System will auto-generate the name based on indicator and the parameter values you specify, but you can change it as desired.

  • Security Parameter

    This represents the security for which this indicator with defined parameters will be computed. Normally, the security is derived from the context. For e.g, when this expression is used in trade order, the security is the same security which is being traded. When this expression is used in screener, the security is the same security which is being processed to determine if it meets the criteria. Hence, normally you will leave it blank. However, in some situation, especially when you are trying to do correlation trading, you want to force particular indicator to always evaluate for particular security, regardless of the context it's been applied. Here is super-simple screener example that shows how useful it is.

    Find all stocks whose last price is greater than today’s open price of AAPL.

    The expression for this will be: LastPrice > OpenPrice_AAPL . You must set security to AAPL when configuring the second variable ( OpenPrice_AAPL ) . If you don’t do that, screener will return all stocks whose last price is greater than its own open price (which is not what you want)

  • Lookback Parameter

    Lookback parameter allows you to reference to previous values of the same indicator. The default lookback is zero, which means it's the current value. Normally, you will leave it as default. Sometimes, if you want to have criteria like, find stocks whose SMA5 is greater than SMA5 20 minutes ago, you will set lookback=20 to reference values 20 minutes ago, assuming you set bar as daily bars. Lookback is dependent on the value of bar parameters. For example, if the indicator is configured for 1-DAY bar, lookback=2 means the value 2-days ago. Whereas, if the indicator is configured on 5-MINUTE bar, lookback=2 means the value 10 minutes before. The value you specify for the lookback is the number of bars to lookback.

  • Add Numeric Values

    To add a numeric value.

    1. Scroll through the list and click on “Number”. Alternatively, enter the number (such as 2), and click on ‘Number’ when it appears in auto-suggest menu.
    2. Configure numeric value dialog will appear.
    3. Provide value and unit ( B, M, K, % )
    4. Click on Save
    number dialog
  • Adding operators

    Select the operator from the list. We support mathematical operators (add, subtract, multiply, divide) and grouping operators ( parenthesis)

    1. Scroll through the list and click on “Number”. Alternatively, enter the number (such as 2), and click on ‘Number’ when it appears in auto-suggest menu.
    2. Configure numeric value dialog will appear.
    3. Provide value and unit ( B, M, K, % )
    4. Click on Save
    number dialog

Modifying variable

After you have added expression items (variables, numeric values etc), you can modify them easily by again clicking on the chip. The same dialog screen that you used to configure and add the indicator variable will re-appear and you can make any edits as necessary.

Modifying variable

You can also delete variables by clicking the cross icon on the chip.

number dialog