fxDreema

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

    variables and constants

    Questions & Answers
    2
    4
    1557
    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.
    • B
      bollitori last edited by

      Hello, is it possible to put a variable on %(#FF80FF)[ modify stops ] ? If it's not, is possible to transform a variable into a constant?
      I would like to change the "take profit" and "stop loss" from %(#FF80FF)[ modify stops ] many times. Also I would like to change the "pips away" from %(#FF80FF)[ pips away from open-price ] . When I say change, I mean to input 5, after the loop 10, another loop 15...

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

        Variables and Constants are both global variables in MQL4, the difference is only that Constants are also external - they serve as input properties of the EA. So at least in MQL4 Constants are not really constants, they can be changed, but I call them Constants (Inputs) because my idea is that they must not be changed.

        There are real constants in MQL4 which can be defined using "const" or "#define" keywords, but you have no control over these from the project in fxDreema.

        So yes, you can use and modify variables as much as you like. They are global and they can be accessed from everywhere.

        The only thing that is quite impossible is to work with a block in the way we work with functions in the programming code. We can call the same function from multiple places in the code, we can reuse it. But blocks in fxDreema are connected to other blocks, so when you run one block it doesn't just return a value, instead it runs the next blocks connected to it. As a result, sometimes you just have to copy that block. But if you actually want to work with all the blocks connected after, then it's ok to call it from multiple places in the code with different values of the Variables.

        1 Reply Last reply Reply Quote 0
        • B
          bollitori last edited by

          So the solution is to repeat for example the %(#FF40BF)[ modify stops ] block and put in %(#FF4000)[ constants ]; my idea is to connect it after a %(#FF4000)[ formula ] that contains a %(#804000)[ variable ] but it returns me a "constant error" or simply it doesn't works. Could you share me an example of a %(#FF00FF)[ modify stops ] blocks with a %(#804000)[ constant ] on pips that changes everytime the block is executed? Or I must copy again and again, as many times as I consider?
          Other question, is possible to know the %(#00FF00)[ "n" ] times that a block passed and put this %(#00FF00)[ "n" ] into a variable or constant?, this %(#00FF00)[ "n" ] can be used in a %(#FF4000)[ formula ] to change a %(#FF00FF)[ variable ] and establish a new %(#FF40BF)[ modify stops ].

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

            Again, variables are totally free. Those are 100% global variables for MQL4 and they can be modified from everywhere. Of course, with the same kind of value. Here is how to modify them in different ways https://fxdreema.com/demo/mt4-variables

            At least tell me which one of your projects does not work or gives an error. I can see you recently worked on many of them, but I can't find something that is using constants and variables in the way described here.

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

            Online Users

            M
            E
            A
            E
            N
            S
            K
            L
            E

            17
            Online

            146.7k
            Users

            22.4k
            Topics

            122.6k
            Posts

            Powered by NodeBB Forums | Contributors