fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Resetting Modified Variables

    Questions & Answers
    2
    4
    1306
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Trader3487 last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        No, but this was requested before, so I'm gonna make it some day.

        1 Reply Last reply Reply Quote 0
        • T
          Trader3487 last edited by

          I found out that if you use a constant in the modify variables block, this effectively resets the variable to original value

          1 Reply Last reply Reply Quote 0
          • fxDreema
            fxDreema last edited by

            "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.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post

            Online Users

            E
            V

            14
            Online

            146.7k
            Users

            22.4k
            Topics

            122.6k
            Posts

            Powered by NodeBB Forums | Contributors