A trading system provides the tools to build, test and depoy trading strategies from within a visual environment, with no coding requirements.

Trading System

Strategy

Trigger Stage

Trigger-On Event

Situation

Condition

Trigger-Off Event

Situation

Condition

Take Position Event

Situation

Condition

Open Stage

Initial Definition

Initial Stop

Phase 0

Formula

Next Phase Event

Situation

Condition

Initial Take Profit

Phase 0

Formula

Next Phase Event

Situation

Condition

Position Size

Formula

Position Rate

Formula

Open Execution

Manage Stage

Stop

Phase 1

Formula

Next Phase Event

Situation

Condition

Move to Phase Event

Situation

Condition

Take Profit

Phase 1

Formula

Next Phase Event

Situation

Condition

Move to Phase Event

Situation

Condition

Close Stage

Close Execution

Trading System

A trading system is a framework handling the low-level logic that serves to structure the processes and methods used to implement and deploy trading strategies.

In practical terms, a trading system is a hierarchical arrangement organizing the actionable aspects of your investment plan. The hierarchy contains definitions regarding any number of trading strategies, all sharing the same market, the same base asset, and the same initial capital.

You use a trading system to define strategies following the Superalgos Protocol, splitting strategies into four stages: trigger, open, manage, and close.

The concept of describing strategies in phases is fundamental to the methodical aspect of the trading system, as it provides a framework to run every strategy with the same logic, which contributes to developing scalable trading systems that may grow to any number of strategies.

When a trading system features more than one strategy, the first strategy has precedence over the second, the second over the third and so on. This means that strategies are evaluated in a sequence. When a given strategy is triggered-on, the remaining strategies in the queue are no longer evaluated until the strategy triggers off. In other words, when multiple strategies are deployed within a single trading system, only one strategy may trade at any given moment, and precedence is given by the order around the trading system node.

Adding a Trading System Node

To add a trading system, select Add Trading System on the workspace node menu.

Strategy

A strategy is a set of actions occurring in stages, designed to achieve a specific goal within a broader plan, via executing trades.

The definition of a strategy may be analyzed in three sections:

A strategy is a set of actions occurring in stages

Strategies are defined in the following steps:

These stages are played in a sequence: once a strategy is triggered it looks to open a position; once a position is open, it is time to manage it as the trade develops; and once a stop or take profit target is hit, it is time to close the position.

designed to achieve a specific goal within a broader plan

Your investment plan or trading carrer may have any number of goals (e.g.: accumulating bitcoin, diversifying on a basket of coins, annual profit targets, etc.). If you attempt to achieve two different goals with a single strategy, you may run into problems. It may be doable, but the strategy would certainly be more complex. In any case, the logical thing to do is to analyze each goal separately so that you can design at least one clear, straightforward strategy for each goal.

via executing trades

The definition of strategy points to the concept of a trade. A trade is a process that exchanges the base asset for the quoted asset and that—after some time, as the trade develops and targets are hit—exchanges back the quoted asset for the base asset. The first and foremost rule of a trade is to preserve capital and its main goal is to increase it.

Adding a Strategy Node

To add a strategy, select Add Strategy on the trading system node menu. The strategy node is created along with the rest of the basic structure of nodes required to define each of the strategy stages and their events.

Trigger Stage

The trigger stage deals with monitoring the market in search of trading opportunities with the corresponding strategy.

A trading system may have multiple strategies designed for the same market, with the same base asset.

An important aspect of trading systems is that they are allocated a certain amount of capital (see the base asset parameter). As a consequence, strategies within a trading system have to share that capital allocation.

The logic behind the concept of the trigger stage assumes that different strategies within a trading system are specialized for trading in different market conditions. The trigger stage in each strategy is, therefore, the mechanism by which any particular strategy may be selected to trade, given any particular market situation.

The triggering-on of a strategy effectively blocks the selection of any other strategy in the trading system, and reserves the whole capital allocation for a potential trade, until the strategy is triggered-off.

As a corollary, if certain strategies are meant to trade under the same market situations and open trades concurrently, then those strategies should be put in separate trading systems.

Adding a Trigger Stage Node

To add a trigger stage node, select Add Missing Stages on the strategy node menu. All stages that may be missing are created along with the rest of the basic structure of nodes required to define each of them and their events.

Trigger-On Event

The trigger-on event defines the set of rules that need to be met for the corresponding strategy to be triggered on. A strategy that is triggered may use all the capital available to the trading system, preventing other strategies in the system from triggering.

In conceptual terms, the trigger-on event is the mechanism you use to define the specific situations in which you would consider trading with the corresponding strategy. Think of the trigger-on event as the definition of the scenario in which the trading idea behind the strategy should be carefully considered.

Once a strategy is triggered-on, the system starts evaluating the take position event. In conceptual terms, it means that the system has been alerted that the trading idea behind the corresponding trading strategy has produced a signal and that it should carefully monitor the market for the opportunity to take a position.

Adding the Trigger-On Event Node

To add a trigger-on event node, select Add Missing Events on the trigger stage node menu. All events that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

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.

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.

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.

Trigger-Off Event

The trigger-off event defines the situation in which the corresponding strategy shall be triggered-off. A strategy that is triggered-off releases the capital in reserve and makes it available to other strategies in the trading system.

In conceptual terms, the trigger-off event is the mechanism you use to define the situation in which the corresponding strategy should stop considering the trading opportunity signaled by the trigger-on event. That is, you use the trigger off event to describe the scenario for the invalidation of the trading idea behind the strategy.

Once a strategy is triggered-on, only two possible scenarios may follow. Either the take position event is triggered, thus, taking a position and opening a trade, or the trigger-off event is triggered first.

In the first scenario, the strategy remains on until the trade is closed. As the trade is closed, the strategy is triggered-off. In the second scenario, the strategy is triggered-off immediately.

Adding the Trigger-Off Event Node

To add a trigger-off event node, select Add Missing Events on the trigger stage node menu. All events that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

Take Position Event

The take position event defines the situation that needs to be met to enter a trade.

The trigger-on event merely selects a strategy to be considered for trading under the current market situation. The actual decision to enter a position may require more specific conditions to be met. For that reason, the take position event is a separate entity from the trigger-on event.

Therefore, the take position event is defined with its own set of situations and conditions.

Once the take position event is triggered, the decision to take a position has been made and there is nothing else to consider in that regard. Therefore, the system shifts from the trigger stage to the open stage.

Adding the Take Position Event Node

To add a take position event node, select Add Missing Events on the trigger stage node menu. All events that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

Open Stage

The open stage deals with all the parameters that define a trade, including position rate and size as well as initial stop and take profit targets.

Conceptually, the open stage deals with the details that concern the opening of a trade once the decision to take a position has been made. In this stage, you deal with the aforementioned parameters, each of which is defined by a formula.

Ideally, the open stage would also handle the parameters that define the execution of the trade, that is, how and which kinds of orders are to be placed, on which exchanges and so on. However, the execution side of the system is still under development. For the time being, execution is drastically simplified: a single market order is placed for each order.

Adding the Open Stage Node

To add an open stage node, select Add Missing Stages on the strategy node menu. All stages that may be missing are created along with the rest of the basic structure of nodes required to define each of them and their events.

Initial Definition

The initial definition node groups the parameters that define the trade at the moment the position is taken.

Adding an Initial Definition Node

To add an initial definition node, select Add Initial Definition on the open stage node menu. The initial definition node is created along with the rest of the basic structure of nodes required to define the initial state of the position.

Initial Stop

The initial stop defines the initial target to stop a loss before the trade gets to be managed.

Notice that the setting of the stop target has no relation to the execution of orders. The stop is a target, not an order to be placed. That is, the system does not place stop orders.

This is a design feature that allows you to keep your cards, not allowing anyone to anticipate what your strategy may be, not even the exchange. It is a known fact that some exchanges may attempt or allow to front-run stop orders.

Instead, the trading bot instance monitors the market, and only once the stop target has been hit does it place the corresponding order to close the trade.

The initial target is set in phase 0, that is, the departing point for the management of the trade to be handled in the manage stage.

Adding the Initial Stop Node

To add an initial stop node, select Add Missing Items on the initial definitions node menu. All items that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

Phase 0

Phase 0 represents the starting point for a stop or take profit target, which may be managed in subsequent phases, on the manage stage.

Adding a Phase 0 Node

To add the phase 0 node, select Add Phase on the initial definitions node menu. The missing phase 0 node is created along with the rest of the basic structure of nodes required to define it.

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 indicators and internal variables made available by the system. 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.

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.

Adding a Formula Node

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

Next Phase Event

The next-phase event is defined by a market situation upon which the management of the trade should shift from one phase to the next phase in a predetermined sequence.

The management of a trade is performed—by default—in sequential phases. Each phase may define a new formula (either for stop loss or take profit targets). To move from one phase to the next, a certain situation associated with the next phase event must be validated. When that happens, the next phase event is triggered and system shifts the focus to evaluate the formulas and the event corresponding to the following phase in the sequence.

Adding a Next Phase Event Node

To add a next phase event, select Add Next Phase Event on the corresponding phase node menu. The event is added along with the basic structure of nodes to define it.

Move to Phase Event

The move-to-phase event is defined by a market situation upon which the management of the trade should shift from the current phase to an arbitrary phase, determined by a reference.

The sequence in which phases are executed may be overriden by the use of the move-to-phase event. When the situation in the move-to-phase event validates true the system shifts the focus to the phase referenced by the move-to-phase event.

Any number of move-to-phase events may be set-up at each and every phase, allowing complete flexibility on how the trade is managed. This feature allows setting complex trade-management algorithms switching to different formulas back and forth or in any configuration imaginble.

Adding a Move to Phase Event Node

To add a move-to-phase event, select Add Move to Phase Event on the corresponding phase node menu. The event is added along with the basic structure of nodes to define it.

Initial Take Profit

The initial take profit defines the initial target to take profit before the trade gets to be managed.

Pretty much like with the initial stop, the initial take profit is a target, and not an order to be placed. Only when the trading bot instance detects that the target has been hit does it place an order to close the trade.

The initial target is set in phase 0, which may shift to the following phase once the corresponding next phase event is validated.

Adding the Initial Take Profit Node

To add an initial take-profit node, select Add Missing Items on the initial definitions node menu. All items that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

Position Size

The size of the position is the amount of capital that will go in the trade, denominated in the quoted asset. The position size node allows setting a size for the position using a formula.

Adding the Position Size Node

To add a position size node, select Add Missing Items on the initial definitions node menu. All items that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

Position Rate

The position rate is the rate at which the position is taken, denominated in the quoted asset. The position rate node allows setting the desired position rate with a formula.

However, for the time being, the formula is overridden by the system as execution is currently limited to market orders until a more robust execution system is deployed. Therefore, the position rate is currently taken from the closing value of the last candle.

Adding the Position Rate Node

To add a position rate node, select Add Missing Items on the initial definitions node menu. All items that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

Open Execution

Open execution is the node that will eventually hold the information regarding the execution of the trade opening orders.

Adding the Open Execution Node

To add an open execution node, select Add Open Execution on the open stage node menu.

Manage Stage

The manage stage is the third stage in the definition of a strategy and deals with the management of stop and take-profit targets.

The management of a trade aims to increase the efficiency of your trading system. Conceptually, a trade is not an instantaneous event, but an event which has an opening, a period of maturation, and a closing. The management of the trade happens in that period of maturation.

The concept of managing the trade means that the formulas to determine the take profit and stop may change as the trade develops. The typical situation in which you may want to change your original take profit and stop formulas is when the trade seems to be going well in your favor.

It may be in your best interest to manage both stop and take-profit targets, moving them in the direction of the trade as the market moves, allowing some leeway for a larger profit than expected and, at the same time, cutting the potential for losses.

The management of the trade is handled in phases. Actually, the management of take profit and stop—while correlated—is done independently of each other, therefore, each concept has its own set of phases.

When a situation defined by a set of conditions is met, the next phase event indicates that the take profit or stop formulas shall be changed. At the moment those predefined conditions are met, you enter the next phase. Keep in mind that the trade is in constant development, so there may be as many phases as you deem appropriate for your particular strategy.

The idea of having different phases comes from the notion that big market moves tend to provide clues as to what may come up next. For instance, rallies may accelerate as more traders join the move. Recognizable patterns may emerge. Signs of exhaustion may be identified.

All of these considerations should feed the dynamic analysis performed as the trade develops, and may be contrasted with the predefined conditions that may push take profit or stop further, entering one phase after the next.

Adding the Manage Stage Node

To add a manage stage node, select Add Missing Stages on the strategy node menu. All stages that may be missing are created along with the rest of the basic structure of nodes required to define each of them and their events.

Stop

The stop node in the manage stage groups all phases managing stop loss targets as the trade develops.

Adding a Stop Node

To add a stop node, select Add Missing Items on the manage stage node menu. All items that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

Phase 1

Phase 1 is the first phase in the management of a stop or take-profit target. The management of targets may have as many phases as required.

The management of phases happens in a sequence. Phase 1 comes after phase 0, which holds the initial definitions for stop and take profit targets. You may continue adding phase 2, phase 3 and so on. Once the next phase event is triggered in one phase, the system applies the targets of the following phase and starts monitoring the situations defined in the corresponding next phase event.

Adding a Phase 1 Node

To add a new phase, select Add Phase on the stop or take-profit node menu. A new phase is added along with the basic structure of nodes required to define each of them and their events.

Take Profit

Take profit node in the manage stage groups all phases managing take profit targets as the trade develops.

Adding a Take Profit Node

To add a take profit node, select Add Missing Items on the manage stage node menu. All items that may be missing are created along with the rest of the basic structure of nodes required to define each of them.

Close Stage

Close stage is not developed yet. In the future, it will deal with the execution of the closing orders, trading log, and related matters.

As explained earlier while discussing the open stage, the execution functionality is currently under development. Needless to say, execution of the closing orders is of the highest significance, but in the meantime some temporal execution limitations apply.

Also pending development is the keeping of a formal trading log. The current functionality allows you to see each trade on the screen, along with all the corresponding details, as well as a consolidated report on the live trading panel. This information is stored as a data product, thus, it is not lost. In the future, the system should incorporate a user-friendly feature to browse such logs, and even help analyze them in search for potential optimizations of your trading systems.

Adding the Close Stage Node

To add a close stage node, select Add Missing Stages on the strategy node menu. All stages that may be missing are created along with the rest of the basic structure of nodes required to define each of them and their events.

Close Execution

Close execution is the node that will eventually hold the information regarding the execution of the closing orders.

Adding the Close Execution Node

To add a close execution node, select Add Close Execution on the open stage node menu.