Skip to main content
Algos - Condition Syntax & Examples

Describes syntax and examples of Algo conditions

APEXE3HQ avatar
Written by APEXE3HQ
Updated over a year ago

Algo's consist of buy and sell conditions, which are evaluated in real-time.

A condition consists of variables and operators.

See here for a definition of all available variables.

The following operators are supported:

  • + addition

  • - subtraction

  • * multiplication

  • / division

  • == equality ( = by itself will not be recognized)

  • > greater than

  • < less than

  • >= greater than or equal to

  • <= less than or equal to

  • && and

  • || or (double pipe - on the keyboard, typically shift + \ )

Precedence

  • ( ) open and close bracket for precedence

Syntax

  • A space is required to separate variables and operators e.g.

    • rsi >= 70

    • sma < c && c > ema200
      ​

  • All variables, referenced in conditions, have to be selected from the variables dropdown
    ​

  • Only variables on the "Select variables:" list will be accepted

  • When writing a variable within a condition, it's case and definition must match how it is listed e.g

    • ema10 (works)

    • Ema 10 (does not work)

    • rsi > 70 && sma < c (works)

    • Rsi > 70 && SMA < C. (does not work)

Examples

  • Bitcoin is ranging between $19,000 and $21,000. Capture alpha while Bitcoin ranges between these levels

    • Use the Buy/Sell algo with the following conditions

      • Buy Condition: c <= 19000

      • Sell Condition: c >= 21000

  • Buy Apple stock whenever the current price exceeds the sma. Sell when the roi is greater than or equal to 1%

    • Use the Buy/Sell algo with the following conditions

      • Buy Condition: sma < c

      • Sell Condition: roi >= 1

  • Buy Solana if the market is bearish and at a price above a support level. Sell if the market becomes bullish and the price approaches a resistance level

    • Use the Buy/Sell algo with the following conditions

      • Buy Condition: histogram < 0 && c >= bollingerLower

      • Sell Condition:
        histogram > 0 && c > bollingerMiddle && c <= bollingerUpper

  • Check every 60 minutes if Ethereum is oversold and trending downwards. Everytime the condition is valid, buy 0.5 Ethereum. Buy a total of 2 Ethereum

    • Use the Accumulator algo with the following settings and conditions

      • Time interval: 60 mins

      • Buy Condition: rsi < 30 && c < ema

      • Unit Amount: 0.5

      • Allocated amount: 2

  • Exit all my IBM positions in a specific portfolio if the roi is greater than or equal to 2%

    • Use the Auto Exit Algo

      • Select the portfolio which consists of the IBM positions

      • Sell Condition: roi >= 2

      • Sell Mode: Sell All

  • Exit my AVAX position in a specific portfolio when it's rsi is greater than 65

    • Use the Auto Exit Algo

      • Select the portfolio which consists of the AVAX positions

      • Sell Condition: rsi > 65

      • Sell Mode: One or More

      • Select the position to exit


        ​

Did this answer your question?