fxDreema

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

    Block "formula" with more operands

    Questions & Answers
    4
    15
    4650
    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.
    • BigMat
      BigMat last edited by BigMat

      The block "formula":
      "makes a simple mathematical operation over two operands - Left Operand and Right Operand - and puts the result into a previously defined Variable. You need to first define that Variable in Variables and then put it (right-click and select) into the corresponding input field."

      What I thought (it's possible?):
      This block makes a simple mathematical operation over two or more operands and puts the result into a previously defined Variable.

      My formula:
      y1=a*x1+b
      Y1, A, X1 and B are variables
      So there are three operands: A, X1 and B
      (Variable A * Variable X1) + Variable B
      Put the result into this variable: Y1

      With the normal formula block, it would be:
      Block Formula 1 A*X1
      Put the result into this variable: BlockFormula1
      Block Formula 2 BlockFormula1 + B
      Put the result into this variable: Y1

      That means a lot more blocks and variables 😕
      What to do?

      1 Reply Last reply Reply Quote 0
      • J
        josecortesllobat last edited by

        You can use a "Custom MQL code" block like this

        0_1558547614237_028dd055-38a3-4a96-8b71-5edac0092712-image.png

        1 Reply Last reply Reply Quote 1
        • BigMat
          BigMat last edited by BigMat

          With this "Custom MQL code" block would be possible to change the variable with other formula? Seems like "Custom MQL Code" works only with MetaTrader functions, not a basic equation changing a fxDreema variable for other blocks, I'm wrong?

          Y1, A, X1 and B are changeable variables from other formulas blocks.

          Thank you

          1 Reply Last reply Reply Quote 0
          • J
            josecortesllobat last edited by

            Here you are defining a variable "Y1" as a result of an math operation. Then, "Y1" value will change in function of the variables "A", "X1" and "B".

            I am not sure what you mean with "Y1, A, X1 and B are changeable variables from other formulas blocks." "A", "X1" and "B" don't matter of where come. They might be a predefined variables or as a result of a formula block. But if "Y1" had a value before of that "Custom MQL code" block, Y1 value will shift to the result of the math operation.

            Y1 = 10
            A = 1
            X1 = 2
            B = 3
            Y1 = 1*2+3 = 5

            Before "Custom MQL code" block -> Y1 = 10
            After "Custom MQL code" block -> Y1 = 5

            Hope this helps.

            BigMat 1 Reply Last reply Reply Quote 1
            • BigMat
              BigMat @josecortesllobat last edited by

              @josecortesllobat said in Block "formula" with more operands:

              Here you are defining a variable "Y1" as a result of an math operation. Then, "Y1" value will change in function of the variables "A", "X1" and "B".

              I am not sure what you mean with "Y1, A, X1 and B are changeable variables from other formulas blocks." "A", "X1" and "B" don't matter of where come. They might be a predefined variables or as a result of a formula block. But if "Y1" had a value before of that "Custom MQL code" block, Y1 value will shift to the result of the math operation.

              Y1 = 10
              A = 1
              X1 = 2
              B = 3
              Y1 = 1*2+3 = 5

              Before "Custom MQL code" block -> Y1 = 10
              After "Custom MQL code" block -> Y1 = 5

              Hope this helps.

              Yeap, you got it! Thank you, worked with three operands (A*X1+B), but...

              I made a little research about operands in /book.mql4.com/basics/expressions and figured out that is impossible to prioritize an addition value than a division, for an example:
              0_1558986328194_20190527-164501-001.png
              And if I try "A=(Y1l-Y2l/X2l-X1l);" it would result first in Y2l/X2l , right?

              So, in one hand Custom MQL Code it's a nice way to shrink sum of variables to one single block, like A1+A2+A3+A4 and so on...
              In the other hand, Custom MQL Code doesn't work with simple equations like (A1+A2)/(A3+A4).

              What's your opinion about that?

              Thank you 🙂

              1 Reply Last reply Reply Quote 0
              • J
                josecortesllobat last edited by

                "Custom MQL code" should work with any math operation if it is well defined.

                Did you try it with an extra parenthesis?

                A=((Y1l-Y2l)/(X2l-X1l))

                ((A1+A2)/(A3+A4))

                I have used that block with equations more complicated than the one you are defining and it worked correctly.

                BigMat 1 Reply Last reply Reply Quote 1
                • BigMat
                  BigMat @josecortesllobat last edited by

                  @josecortesllobat said in Block "formula" with more operands:

                  "Custom MQL code" should work with any math operation if it is well defined.

                  Did you try it with an extra parenthesis?

                  A=((Y1l-Y2l)/(X2l-X1l))

                  ((A1+A2)/(A3+A4))

                  I have used that block with equations more complicated than the one you are defining and it worked correctly.

                  Working with an extra parenthesis 🙂

                  By the way, what you mean with "equations more complicated"?
                  It's possible to solve exponentiation like A=((Y2l-Y1l)²/(X2l-X1l)³) or A=((∛Y2l)-(Y1l))?
                  Or even group equations in one block, like Y1=(A*X1+B);Y3=((Y2-Y1)/(X2-X1)); ?

                  Thank you very much for your contribution! Your investment in time and energy was far beyond what I could have asked for :]

                  1 Reply Last reply Reply Quote 0
                  • J
                    josecortesllobat last edited by

                    You can code what you need but you have to know how to use the math functions.

                    https://www.mql5.com/en/docs/math

                    Like

                    0_1559054335100_11f4d42b-7280-4461-affa-933b448c0500-image.png

                    BigMat 1 Reply Last reply Reply Quote 1
                    • BigMat
                      BigMat @josecortesllobat last edited by BigMat

                      @josecortesllobat said in Block "formula" with more operands:

                      You can code what you need but you have to know how to use the math functions.

                      https://www.mql5.com/en/docs/math

                      Like

                      0_1559054335100_11f4d42b-7280-4461-affa-933b448c0500-image.png

                      So, in the example, would be: A=((sqrt(Y2l)-(Y1l));
                      Oh, I almost got it...
                      How it would work with ∛ or ∜ or other custom number?

                      How it would work with MathExp or exp()?

                      And it's possible to group equations? How?
                      Edit ~ Seems that worked:
                      0_1559058646650_20190528-125033-001.png
                      So, I can group endless equations? Like all my "formulas block" united in one "Custom MQL Code"?

                      Thank you

                      1 Reply Last reply Reply Quote 0
                      • J
                        josecortesllobat last edited by

                        Yes, you can.

                        I would say that is this

                        0_1559060155820_a252455a-4e10-4cfe-9db4-af5670a68a66-image.png

                        But I have not tried it.

                        BigMat 1 Reply Last reply Reply Quote 1
                        • BigMat
                          BigMat @josecortesllobat last edited by

                          @josecortesllobat said in Block "formula" with more operands:

                          Yes, you can.

                          I would say that is this

                          0_1559060155820_a252455a-4e10-4cfe-9db4-af5670a68a66-image.png

                          But I have not tried it.

                          Running very well, thank you 🙂
                          I tried that:
                          0_1559266042336_20190530-222057-001.png
                          And got the right result!

                          How it would work with MathExp or exp()?

                          Best regards

                          1 Reply Last reply Reply Quote 0
                          • J
                            josecortesllobat last edited by

                            I would say that is like this

                            0_1559324419040_098453a3-1e99-408c-b297-43e20d14542e-image.png

                            But I don´t test it.

                            1 Reply Last reply Reply Quote 0
                            • M
                              mariussun last edited by

                              Is the same for mq5 or works only mq4? I don't succeed for mq5.

                              l'andorrà 1 Reply Last reply Reply Quote 0
                              • l'andorrà
                                l'andorrà @mariussun last edited by

                                @mariussun If that is confirmed, could you please open a thread on the 'bugs' forum? That way the admin will be able to see it.

                                (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                                1 Reply Last reply Reply Quote 0
                                • M
                                  mariussun last edited by

                                  Thank you, Meanwhile I've succeed to resolve the issue.

                                  It seems that it's working well in the end..:)

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

                                  Online Users

                                  E
                                  N
                                  N
                                  F
                                  M
                                  A
                                  L
                                  O
                                  S

                                  24
                                  Online

                                  146.7k
                                  Users

                                  22.4k
                                  Topics

                                  122.6k
                                  Posts

                                  Powered by NodeBB Forums | Contributors