fxDreema

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

    Two conditions are met.

    Questions & Answers
    8
    15
    5476
    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.
    • J
      Juan Manuel Quiñonero last edited by Juan Manuel Quiñonero

      Hi. How can I do, if two conditions are met, open an operation?
      These conditions are separated by an indeterminate number of candles.
      For example a junction of EMAS and a stocahastic level.0_1536516698598_a957a360-8672-47b8-969a-bd3ef0bab4e3-image.png

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

        Must both conditions to be meet at the same time/candle?

        1 Reply Last reply Reply Quote 0
        • J
          Juan Manuel Quiñonero last edited by

          Not in the same candle.
          First one and then the other, but not in consecutive candles.
          There may be a separation of x candles.

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

            You can try this

            0_1536520571753_6ed5a240-a30f-4bd6-9c89-7d1b0a4ea7ab-image.png

            Define a variable like -> bool FirstCondIn == false

            If FirstCondIn == false, the true block (2) output Will pass and the EA Will look for the 1st condition.

            If the 1st condition is met, the true block (3) output Will pass and FirstCondIn == true

            As the FirstCondIn == true, the yellow block (2) output Will pass and the EA Will look for the 2nd condition having the 1st as true. While FirstCondIn == true, the EA Will not look for the 1st condition until block (7) reset its value to false.

            C E V 3 Replies Last reply Reply Quote 0
            • C
              cristobaljosemt5 @josecortesllobat last edited by

              @josecortesllobat

              Hello and what modification should I do so that when this pattern is given and I am buying it, I will not go back to doing another operation until the first condition returns to resfresh or give?

              J 1 Reply Last reply Reply Quote 0
              • J
                Juan Manuel Quiñonero @Juan Manuel Quiñonero last edited by

                @juan-manuel-quiñonero Gracias Jose

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

                  @cristobaljosemt5

                  Take a look at the example. The first condition is only checked when "No Position" block is true. So, if there is a trade running, it is not allowed to open a new trade.

                  C 1 Reply Last reply Reply Quote 0
                  • C
                    cristobaljosemt5 @josecortesllobat last edited by

                    @josecortesllobat

                    True the problem is when once the 1st condition is given and every time that the 2nd condition will come back to operate, in my case I want that for every time the 1st condition is once again only operated once when the 2nd condition, in this way we have this sequence: 1st condition + 2nd condition = to a single operation and until the 1st condition does not return to be added to the 2nd again again no more operations are established

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

                      When you have variables, you can modify them as you want. You set the variable for the first condition to "true" when the condition is true, then the variable remains "true" until you set it to "false", which can be at any time.

                      But always try to think, is it even needed to do this stuff. Because you can just check 2 condition at the same time:
                      1 - Is the current price below MA
                      2 - Is oscillator above level X

                      Depends on the first condition. You don't say exactly what it is, so for me it looks like it is: Price crosses MA. But you know, if at the current moment Price is < MA, this means that some candles ago the price crossed MA. The question is, do you even care when that happened...

                      C 1 Reply Last reply Reply Quote 0
                      • C
                        cristobaljosemt5 @fxDreema last edited by

                        @fxdreema

                        Hi, I try to explain it better, the conditions are these:
                        1º Once the rsi crosses 70 or 30 for purchase or sale, this is waiting for the 2nd condition to occur.
                        2º The 2nd condition would be the crossing of the line 0 of the macd, but only for once, that is to say that if there are new crosses to the zero line that does not introduce more operations until the 1st condition changes.

                        Explain me well? Thanks for everything

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

                          I think the best in this case is what josecortesllobat explained above. There are basically 2 ways to do such thing - starting from the current candle to look in the past candles and detect the signal, or while the EA is running to wait for each signal to happen (and use variables to store the current state). I generally prefer the first method when it's easy enough to use it, and it can be used in some custom indicator, but I don't think that it's a good idea in the EA.

                          By the way, here is another interesting method: https://fxdreema.com/demo/mt4-wait-crossovers But I don't think that this can be used for your case.

                          1 Reply Last reply Reply Quote 0
                          • L
                            Luisen last edited by Luisen

                            I have the same problem that cristobaljosemt5 ,

                            @cristobaljosemt5 , Have you solve the problem?

                            My steps are:

                            1. price down the MA and blue arrow
                            2. rsi > 70
                              open buy
                              I copy just the same of the example, and the problems is that when the trade is finish the EA should come back again to the first condition , and it doesn´t do it
                              i attached a screenshoot and the EA
                              ![alt text](0_1555544936368_captura_melm13.png image url)0_1555545065567_Melm 13 (27).mq4

                            In adition i have another problem, If i put a secon block in the second condition (on the right side) the EA dont make trades.

                            Thanks for teh help and Regards

                            1 Reply Last reply Reply Quote 0
                            • E
                              edward brazil @josecortesllobat last edited by

                              @josecortesllobat , hi, i am trying to use this same concept, but i do not now what to put in description of the variable, could you help?

                              T 1 Reply Last reply Reply Quote 0
                              • T
                                trader.philipps @edward brazil last edited by

                                @edward-brazil 0_1569190766917_Auswahl_570.png
                                Number (1) is okay. That is the first occurance that your indicator value crossed up (or a bit later) below your clipping level. But what abot the case I marked with (2)?

                                If that is also a valid entry, than your first condition is that price closes below the Moving Average or whatever indicator is on the chart and you take all occurances that your oscilator brakes some clipping level.
                                If you only wnat to take the first occurance, than it's a bit more tricky.

                                I like to share my knowledge, but expect the others to contribute as well.

                                1 Reply Last reply Reply Quote 0
                                • V
                                  venous @josecortesllobat last edited by

                                  hi dear friend
                                  wath is the name oh block number 4 ?

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

                                  Online Users

                                  S
                                  A
                                  M
                                  R
                                  G
                                  T
                                  G
                                  Y
                                  C
                                  S
                                  S
                                  S
                                  A

                                  28
                                  Online

                                  146.7k
                                  Users

                                  22.4k
                                  Topics

                                  122.6k
                                  Posts

                                  Powered by NodeBB Forums | Contributors