Visualization module to build trading strategies - in-depth (1)

in #fmz9 months ago

Logic module type

1. Conditions module
This module is used to combine conditional judgment, and the module can add multiple conditional branches.
Click the small "gear" icon to add conditional branches.

1.png

The example use of conditional modules is tested in combination with the next module.

2. Numerical comparison module
This module is used to compare two numerical values (you can also think of this module and the numerical module combined into an expression module), and return to a boolean value.
This module can determine whether the value on both sides is "greater than", "less than", "greater than or equal to", "less than or equal to", "not equal to", or "equal to".
The tenon (concave) positions on both sides of the drop-down box option can be embedded in numerical and variable modules (as long as the modules that return numerical values ​​can be embedded).

2.png

An example of using the "conditional block" and "value comparison block" to form a judgment value:

3.png

It can be seen that this example has a total of 3 branches when judging the conditions.

Like the use of if statements in JavaScript strategies.

function main () {
    var a = 1
    var b = 2
    if (a > b) {
        Log("a > b")
    } else if (a < b) {
        Log("a < b")
    } else {
        Log("a == b")
    }
}

3. logical OR, logical AND module
This module is used to perform "OR operation" or "AND operation". The tenon (concave) positions on both sides of the drop-down box in the middle of the module are embedded in the module involved in the calculation (it can be a module that returns to a boolean value or numerical value).

4.png

Before testing this module specifically, let's learn the module representing the boolean value "true"/"false" (set with the drop-down box), the module representing the boolean value "not", and the module representing the null value first.

5.png

Null modules, which represent the null value in code, are used to compare whether some variables are null.
Modules with boolean values ​​of "true"/"false" represent the true / false values ​​in the code, which are used to determine the boolean values ​​returned by certain modules or combinations of modules.
The "NO" module of boolean value represents the ! in the code, which is used for Boolean NOT calculations.
Test example:

6.png

We can see that the "logical OR, logical AND" modules can also be nested.

Nested module splicing example:

7.png

Equivalent JavaScript strategy code:

function main () {
    var a = 1 
    var b = 2
    Log((true && !false) || (a==b))
    Log(null)
}

!false is not false, that is, true value, logical expression: (true && !false): two true values ​​are performed and calculated, the result is true.
a == b is obviously not equal, so it is false.
A true value and a false value perform a logic or calculation, and the result is true.

Operation result:

8.png

To be continued...

Sort:  

You've got a free upvote from witness fuli.
Peace & Love!

Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.027
BTC 60629.29
ETH 2636.33
USDT 1.00
SBD 2.51