fxDreema

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

    Absolute Value Function

    Questions & Answers
    3
    6
    3144
    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
      Blockhead last edited by

      fxDreema is there a way of creating the absolute value of a variable?

      For example: The absolute value of (3-5)=2

      I want to take the difference of the current bar(0) close from the close 10 bars ago and make it so that all are positive in case they are negative after subtracting.

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

        There are no conversion blocks, but the native MQL4 functions are not hard to use:
        http://docs.mql4.com/math/mathabs

        MathAbs(3-5) should give you 2.

        1 Reply Last reply Reply Quote 1
        • M
          MetaTrader last edited by

          I am looking for the same more or less, where to put that?

          example:
          Current price should be below or above an indicator value not more than for e.g. 10 pips
          If I use a formula block
          on the left side the indicator
          operator minus
          on the right side the price

          is half the way.

          Where can i put the MathAbs function call now?

          Or any other szenario where i want to use MathAbs or any other MT4 function.

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

            MQL functions can be used everywhere, all input fuelds in all blocks accept MQL code. The problem is that MathAbs() accepts input parameter between ( and ) and this parameter must be also written manually. If Variable is used it will not look as the blue thing. It will look like this: http://prntscr.com/9f2sil

            1 Reply Last reply Reply Quote 1
            • M
              MetaTrader last edited by

              Not clearly explained 😞

              Which varname should be written there?

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

                The one from which you want to get absolute value

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

                Online Users

                L
                S
                A
                F

                21
                Online

                146.7k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors