Logo Compose your trading system through a user friendly
graphical interface and see when to go long, short or liquidate.

Output Manipulation

Here concepts relating to the manipulation, or transformation, of the algorithms' output are introduced.

Outputs of elementary trading algorithms can be further refined by extra-functionalities. They can be negated (NOT), they can be considered true only when transitioning from false to true (step) and they can be considered valid even for the next intraday (extend).

Output Manipulation

Output Manipulation

Checkboxes In order to compose more powerful trading systems, Trading Conceiver lets you manipulate the output of the algorithms. This is enabled through checkboxes. The usefulness and examples of this will be explained later. Now focus on the concept and, above all, what happens in the case of intervals and intraday trading.
Order of Application
If multiple checkboxes are selected, the manipulations are applied in the order they appear in the checkboxes:
  NOT → Step → Extend

NOT

NOT NOT The logical NOT operator negates its input. It is also called complement. True becomes false and vice versa.
At Open and Close
For the boolean value at Open and Close this is straightforward.

  Straight ║  NOT
  ─────────╫──────
   true    ║ false
   false   ║ true  
At Threshold
For the value and interval at Threshold, things get trickier. Negation is performed by complementing the interval. Then the boolean value is set to true if the complement of the interval is not empty; it is set to false otherwise. So the boolean value is not simply the negated of itself, like in Open and Close. The boolean value simply says if there is at least one value between low and high where the algorithm is true.
Example
Let's suppose we have the following values:

            ↑
            │
       high ┼
            │
  threshold ┼
            │
        low ┼
            │ 
  
Here is a list of intervals with the corresponding boolean values, before and after applying the NOT logical operator:

            Straight          ║            NOT 
                              ║
  boolean │     Interval      ║ boolean │    Complement
  ────────┼───────────────────╫─────────┼──────────────────
    true  │ [low, threshold]  ║  true   │ [threshold, high]
    true  │ [threshold, high] ║  true   │ [low, threshold]
    true  │ [low, high]       ║  false  │ ∅ (empty set)
    false │ ∅ (empty set)     ║  true   │ [low, high]
  
Always Prefer the 'Straight' Algorithm
Often, but not always, for a given elementary algorithm, it already exists another elementary algorithm which is its complement, i.e. the algorithm obtained by applying the NOT operator. For example:
  Angle of MA of Stochastic positive    [1]
  Angle of MA of Stochastic negative    [2]
These are the NOT of each other. So in theory these are equivalent:
  NOT (Angle of MA of Stochastic positive)    [3]
  Angle of MA of Stochastic negative          [4]
However, the second version is faster, because it is calculated directly, whilst the first one is calculated in its straight form first and then negated. The negation is what it renders it slower. So always prefer the straight version of an algorithm if it exists to a NOT version.
Not a Strict Equivalence
More accurately, the previous expressions [3] and [4] are not equivalent, because they check for strict inequality (> and < respectively). Therefore, when the angle is exactly 0, both [1] and [2] are false, and consequently [3] and [4] differ:
  NOT(false) = true    [3]
  false                [4] 
That's a mathematical difference that usually does not change anything, though, because in the real world it is an inane distinction. Besides, we could have legitimately defined the algorithms checking for a non-strict inequality as well (≥ and ≤). Singularities like these get cancel out even at Threshold when dealing with intervals, because intervals are always considered closed. Indeed, we can simplify things considering the intervals always closed and never open because in the real world that is an irrelevant distinction.

Occasionally, for some algorithms this distinction may be meaningful. For instance:
  Donchian channel upper line greater than MA    [5]
  Donchian channel upper line less than MA       [6]
are "almost" the negated of each other. But the Donchian channel is flat, that is horizontal, for long periods. So its moving average is often flat, too, exactly at the same level of the upper line. So oftentimes [5] and [6] are both false, and negating one of the two, results in them differing for long periods of time.

Step

NOT The step manipulation detects where an algorithm transitions from false to true. After applying the step, the resulting algorithm is true only where the original algorithm toggles from false to true.
Instants in Time
Only at Close
If the algorithm is defined only at Close, then only the boolean values at close are compared. In this case, the step can be present only at Close.
Intradaily
If, on the contrary, the algorithm is defined intradaily, then the boolean value at Close is compared with the boolean value at Threshold; the boolean value at Threshold is compared with the boolean value at Open; the boolean value at Open is compared with the boolean value at Close of the previous bar. In this case, the step can be present at Open, Threshold and Close.

Extend

Extend The Extend functionality is used to make a trading system, operating only at close, to operate also intradaily.
Two Legitimate Possibilities
Most of the indicators found in literature are calculated using the closing price. So they are well known at the close instant in time. What happens from open to close? Both the following are legitimate assumptions:
  • From open to close the indicator is not defined, so it does not exist.    [5]
  • From open to close the indicator takes on the same value as the preceding close.    [6]
The first assumption is straightforward. The second implies that once calculated, the indicator keeps the same value until it is updated. As updates are made at close, this means that at next open and throughout the next day it will maintain the value of the previous close.
Combination of Algorithms
This difference is irrelevant when dealing with indicators per se, but is pivotal for trading algorithms, derived from indicators or not. In order to build a real trading system, algorithms must be combined together. This means that their outputs must be compared and, based on their reciprocal values, a new output is built. The combination occurs for each of the 6 tabs of the Composer and is performed through logical operators, like OR and AND.
How to Combine Intraday and Non-Intraday Algorithms?
Suppose you have, in the same tab of the Composer, two algorithms, one valid only at close and the other valid throughout the day. How do you combine them intradaily? As both assumptions [5] and [6] are sound, we allow both.
Default
By default, assumption [5] holds, so it doesn't exist intradaily. In this case, when combined with another algorithm operating intradaily, the combination will be valid only at close, while during the day it will not be computed.
Extend
If you want to opt for assumption [6], you must apply the Extend manipulation option. It copies the boolean value at Close to the next Open and Threshold. The name comes from the fact that we 'extend' the close value to be valid to the next bar, until the next close. In this case, when combined with another algorithm operating intradaily, the combination will be valid and computed not only at close, but throughout the day.
Interval at Threshold
The Extend option copies the boolean value of the previous Close to the current Threshold phase. The extended boolean value holds for the entire intradaily duration of time, whatever its range of price values is. Therefore, if the boolean value was false at Close, at Threshold the extended algorithm is always false, or, put another way, the interval where the extended algorithm is true is the empty set. If the boolean value was true, the interval where the extended algorithm is true is the universe interval at Threshold:
  [low, high]