Building interface

In the "Interface" section of the editor, you can create the interface of your trading robot. You can assign certain actions to buttons, and you can link input fields to variables. All interface elements can be modified using the "Modify interface element" block. All this allows you to create complete and flexible interfaces.

Interface elements stylization

All interface elements have appearance settings. To open the settings of an interface element, you need to double-click on the edited element:

Assigning actions to buttons

You can assign actions to buttons. To do this, in the parameters of the button, you must specify the ID of the block that must be executed when the button is pressed.

Let's say we want to make a purchase when the "Buy" button is clicked and make a sale when you click on the "Sell" button.

For this we should create 2 constants:

  1. symbol - traded symbol code

  2. lot - number of lots our robot will trade

Let's create a simple interface consisting of two buttons and a rectangle as a background:

Place 2 "market order" blocks with the following parameters on the robot logic scheme:

Now we just need to bind the "market order" blocks to the corresponding buttons.

To do this, copy the ID of each "market order" block and specify the copied IDs as the "Linked block ID" parameters of interface buttons.

To copy a block ID, you need:

  1. Press "Ctrl"

  2. Without releasing "Ctrl", double-click the block

As a result, a message indicating that the block ID was successfully written to the clipboard will appear.

Copy the ID of the "market order" block with the "buy" direction and paste the copied ID into the "Linked block ID" of the "Buy" interface button:

Do the same for the "Sell" button. Run the robot in the terminal and check its performance:

When the "Buy" button is pressed the robot makes a purchase, when the "Sell" button is pressed the robot makes a sale.

Binding input fields to variables

Sometimes it is necessary to modify the values of variables through the interface of the trading robot. For this purpose, there is the "input field" interface element block.

The input field has a "linked variable" parameter. If the input field has a linked variable, then every time the input field is changed, the linked variable will be changed according to the new value of the input field.

Let's make an improved version of the previous example. This time, "symbol" and "lot" will not be constants, but variables. For these variables, we make input fields using which we can change the values of these variables on the fly.

So, let's create "symbol" and "lot" variables:

Let's build the interface of our robot:

The first input field is linked to the "symbol" variable, the second input field is linked to the "lot" variable.

Then, drag two "market order" blocks onto the robot's logic scheme, set parameters for these blocks, and link them to the corresponding buttons on the interface:

Note, this time variables, are used as "Symbol" and "Lot" parameters, instead of constants.

Launch the robot and check its functionality:

Using the input fields we can easily change variables values - we can change the symbol on which transactions will be made and the number of lots traded.

Interface elements modifications

Using the "Modify interface element" block, you can change the properties of interface elements.

With the "Interface element information" block, you can get the value of a certain interface element property, such as its X or Y coordinate.

Last updated