Resetting Modified Variables
-
Is there a way to reset variables that were modified using the "Modify Variables" block back to their original values defined in the "Project Variables" box?
For example variable "Variable1" is set to numeric value of "10" in project variables box. Then, value is modified using "Modify Variables" block to "Variable1" + 20. So, on the next tick value will be 30, in 2 ticks 50, in three ticks 70, etc.
-
No, but this was requested before, so I'm gonna make it some day.
-
I found out that if you use a constant in the modify variables block, this effectively resets the variable to original value
-
"Constants" and "Variables" in fxDreema are basically the same thing in MQL4 and MQL5 - global variables. The difference is that Constants are automatically set as input parameters (to be seen in Inputs list), in other words they have "extern" (MQL4) or "input"(MQL5) in front of them. What is specific in MQL5 is that input global variables cannot be modified inside the code, while in MQL4 they can... but I will recommend to use Constants as constants in MQL4, to not modify them in the project. Also, you can't define Constant and Variable with the same name... at least this will not work in MQL4/MQL5, you will see an error message.
But you can define a Constant (if it should be in Inputs, otherwise a Variable will also work) like "Hello" and a variable like "vHello" and set "vHello" as "Hello" in order to "reset" it.
If I'm gonna do the functionality to reset variables, it will be something like this, but... now I'm not so sure that this is a great idea, because now you can set a Variable to be Input (to be Constant) and if there is a functionality to reset that Variable... well, in MQL5 it will not be possible, and I also know that MetaQuotes are in process of changing MQL4 to be the same as MQL5.