#Constants and Variables?

If you are a programmer, you know what constants and variables are in the code. In the Builder these words mean something a little bit different:

  • Variables - For the fxDreema project, these are global variables, accessible from all blocks. In the output code they are not exactly global variables.
  • Constants - Similar to the Variables, but the idea is that they should not be modified. These are also input parameters of the robot. In the output code they are not really constants.
  • Terminal Variables - Another kind of variables. These are global variables for the terminal (MetaTrader) and they are actually called Global Variables there. They are used to pass information between robots, or to store information for few days.

#Project Constants (Input Properties)

In fxDreema you can define a single Constant and use it in multiple blocks. In addition, this Constant is also an input parameter for the robot and you will be able to also use it for optimizations.

Click on Constants (Inputs) to create a new Constant or edit already created Constants.

fxDreema Constants (Inputs)

Once defined, Constants can be rearranged.

Then, in any block you can select a Constant to replace a parameter. Just right-click on the input field you want to replace:

fxDreema Constants (Inputs)

Here is an example that shows how Constants can be used:

Single Constant can be used in more than one blocks at once - Constants are global. That's why when changing the Constant's value (from the robot's input parameters), this affects all blocks where it is used.

Don't try to modify a Constant in the project. The very word suggests that it should remain unchanged. If you want to do this, use Variables.

#Project Variables

Variables are similar, but slightly different than Constants. Project Variables are also global and they can be used the same way as Constants, but in addition their values can be modified. So, use Variables when you want to use a value which can be modified in any block.

Here is how to define Variables. Click on Variables to open this window:

fxDreema Variables

In the blocks you can read and modify Variables in various ways. Check out the next example:

#Terminal Variables

Using Global Variables

In MetaTrader you have Global Variables, which are called Terminal Variables in fxDreema only to lower the confusion with the other types of variables. These global variables are used to transfer information between robots or as a persistent memory, due to the fact that they are stored on the file system for 4 weeks.

You should only use these variables to store numeric values. Strings doesn't work here. Here is more information from the official documentation:

You can set these variables in Terminal variables and get them in Condition (or other blocks), as it's shown in the picture below:

Using Global Variables

And of course you can see the current values and also modify them in MetaTrader when you go to Tools -> Global Variables:

Using Global Variables