Using Technical Analysis in a Cryptocurrency Trading Algorithm

Sun Nov 06 2022

In trading, technical analysis is used to confirm or discover new opportunities in the market. With traditional trading, signals are interpreted and acted upon manually. However, in algorithmic trading it’s possible to create a set of logic that will be automatically interpreted based custom conditional logic.

It may sound complicated, but it’s actually quite easy to implement and it can help discover new strategies or automate existing ones.

With algorithmic trading platform Æsir, it’s possible to automate nearly every crypto trading strategy that relies on Technical Analysis by using the Technical Analysis Layer.

In addition to the General Configuration Options, which need to be defined for any crypto trading strategy, the Technical Analysis Layer will allow you to create complex custom logic with little effort.

You can create TA Logic using the following fields in a few simple steps:

1. Select a Candle Interval

This represents the interval of time that each Indicator (selected below) will operate on. For instance if you are comparing EMA50 to EMA20, and your Candle Interval is 1m, then both indicators will use the same 1 minute interval.

2a. Add Condition

Adding a condition allows you create a logical expression comparing an Indicator against a different Indicator or an absolute value. Starting with a single condition will allow you to create a simple signal sign such as EMA20 > EMA50.

2b. Add Logic Tree

A logic tree on the other hand, adds an additional logic layer and a pair operator. This means that logic trees allow you to create multiple conditions. Without the logic tree, your expression is a single comparison, for instance: EMA20 Is greater than EMA50. Adding a Logic Tree instead of a Condition creates a slot to add more conditions or more logic trees, allowing you to continue nesting more and more conditions separated by a Pair Operator.

Each Add Condition Block contains the tools you need to value a technical analysis expression. Let’s break them down below:

3. Select Indicator

Allows you to choose any indicator to be evaluated.

4. Select Operator

Defines how the indicator will be evaluated against the other indicator / value.

5. Select Indicator / Value

Represents the item that the initial indicator will be evaluated against. This can be any other indicator or an absolute value.

If you’ve started with a single Add Condition and no Logic Trees. This should be all that you need in order to add technical analysis to you trading algorithm.

Pair Operator

If you’ve started with Logic Tree instead, you will notice that there now two logic boxes connected by a Pair Operator.

When adding another logic tree, this will create a new Pair Operator allowing you to choose how two or more conditions will be evaluated. The relationship between conditions can be: AND, OR. You will then need to populate both sides of the Logic Tree in order to have a valid expression. With a single logic tree, you expression could be something like this:

SMA10 > SMA 50 AND AO > 0


We’re going to build technical analysis logic that evaluates a simple moving average against another, and ensures that the Awesome Oscillator is above 0 on a 5m candle interval.

Start by selecting a Candle Interval of 5m and then adding a Logic Tree.

Now Add a Condition in the first box. This will check that SMA10 is Greater than SMA50. Now in the pair operator (the input between the two logic boxes) we’re going to select AND.

Finally, in the second box we’re going to Add another Condition. We would create even more complex logic if we added another Logic Tree instead. In the new logic box we’re going to populate the Indicator, Operator and Indicator / Value fields with: AO (awesome oscillator) is Greater than 0.

The signal is now finished and it will read like so: Æsir will place a buy order when SMA10 is greater than SMA50 AO is greater than 0. Because we’ve used an AND operator, this means that both sides of the expression need to evaluate to true before an order can be placed. Similarly, with more complex logic, all or some parts of the expression need to be true in order for buy order to be placed.

Deep Nested Logic

What makes this Technical Indicator layer great is that you can create any form of logic, so long as you’re aware of what it actually does. Let’s take a look at some more advanced use cases for it. If we start by creating a Logic Tree for our technical analysis algorithm like so:

But then instead of adding a condition, we add Another Logic Tree in Each box, we’ll end up with a total of 4 Add Conditions. This means that now the first 2 conditions are nested in box A and the other 2 are nested in box B.

This setup will create a logic expression that looks like this:

(SMA10 > SMA50 AND AO > 0) AND (EMA10 > EMA50 AND RSI >70)

The above expression will only evaluate to true if every member of that expression is true. However, if we change the inner Pair Operator from AND to OR, it will now evaluate to true if one of the nested conditions is True.

(SMA10 > SMA50 OR AO > 0) AND (EMA10 > EMA50 OR RSI >70)

You can keep nesting conditions to create deep complex nesting for any kind of technical analysis crypto trading algorithm. If you don’t have an Æsir account, you can easily create one here to start creating powerful trading algorithms.


©DEM Group 2022