fxDreema

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

    Formula to compare two MA vlaues

    Questions & Answers
    2
    6
    1700
    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.
    • N
      Niceperson last edited by

      I am working on an EA to provide buy signal when ...

      (Condition 1) the MA(5) crosses above MA(10) on third bar before the current bar
      AND
      (Condition 2) if the difference between MA(5) and MA(10) on current bar is more than 50 points.

      I could create the condition block for the first condition, but I can not find a way to create the second condition. I tried the formula block but could not really get it.

      Does someone know of any example? Please guide me with some images / examples.

      Thanks

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

        You can use "Adjust" field for that. For example:

        • MA(5) + 0.0050 > MA(10)
        • MA(5) > MA(10) -0.0050
          where "+0.0050" or "-0.0050" is written in "Adjust" field. You can also write "+50pips" or "-50pips" there.
        1 Reply Last reply Reply Quote 0
        • N
          Niceperson last edited by

          I am testing two conditions for two different shift values and there is an AND operator also. The first condition is for shift value of 3 whereas the second condition is for the current bar. So how do I format the adjust parameter will will take care of these two different shift values? I also need these shift values to be user configurable so that I can change them from the parameters screen of the EA.

          Thanks

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

            http://fxdreema.com/shared/AyQm2K6nc

            And it's much better to connect two (or more) blocks one after another instead of connecting them in parallel and then use AND.

            1 Reply Last reply Reply Quote 0
            • N
              Niceperson last edited by

              I am trying to create a copy of all the boxes on this ea. When I use the constants I get too many compilation errors like
              Compilation errors
              'free' - unexpected token
              'inp2_Lo_SHIFT' - expression on global scope not allowed
              'inp2_Lo_SHIFT' - variable not defined
              'CrossBeforeBar' - expression on global scope not allowed
              'inp2_Lo_SHIFT' - variable not defined
              'inp2_Lo_SHIFT' - variable not defined
              'inp2_Lo_SHIFT' - variable not defined
              'inp2_Lo_SHIFT' - variable not defined

              'MAdiff' - an operator expected
              '=' - assignment expected
              'MAdiff' - semicolon expected
              ';' - assignment expected
              rrors--4
              ee logfile "C=\Program Files\MetaTrader 4 - Exness\experts\FxDr MA 031367548439.log"

              I get no compilation errors without usage of constants.
              Is it becasue I am working on free version? or some thing else?

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

                It's something else. Don't check input parameters checkbox when using constant.
                You can export .mq4 file from the shared project and then import that file into your projects.

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

                Online Users

                Y
                A
                F
                S
                D
                B
                Y

                13
                Online

                146.8k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors