fxDreema

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

    How to check if the last 30 candles are closed above moving average?

    Questions & Answers
    6
    13
    2045
    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.
    • Z
      ZhAhZ last edited by

      Hi, I would like to put condition to check whether the last 30 candles are closed above 100 Moving average. So far could not realize a practical way. Does someone know how to do that?
      The current condition block only compares the current value of the moving average with older candles, but this does not translate to the fact that the those past candles have been above the MA in their own time.

      bk7 jstap 2 Replies Last reply Reply Quote 0
      • bk7
        bk7 @ZhAhZ last edited by

        @zhahz
        loop the last 30 candles and break the loop if a condition isnt met

        Z 1 Reply Last reply Reply Quote 0
        • Z
          ZhAhZ @bk7 last edited by

          @bk7 I made the below loop based on an advice from one of the forum members. However, it does not work when I run the program. No orders will placed if I activate this loop. Please see below link (disregard the first 3 block on top, just put something in there to show you what is the general trend of my EA).
          https://fxdreema.com/shared/eCeLfRnE

          bk7 1 Reply Last reply Reply Quote 0
          • TipsyWisdom
            TipsyWisdom last edited by TipsyWisdom

            i feel like thats totally illogical and this would probably work....

            For longs

            1. if no position (be sure to specify in that block as well as all symbols and all groups)
            2. ma5 on c1 is above ma 20 on c1. current time frame
            3. candle 1 cross above ma 100 (very important, there is now a cross width to can edit in between the 2 ampersands now, that will let you select 30). current timeframe.
            4. final condition for c1 to do something. current time frame.

            Do not share any of the blocks with the sell side and recreate for that with opposing conditions if thats what works.

            Z 1 Reply Last reply Reply Quote 1
            • bk7
              bk7 @ZhAhZ last edited by

              @zhahz

              this should work:

              https://fxdreema.com/shared/b99JZ1ted

              Z 1 Reply Last reply Reply Quote 3
              • Z
                ZhAhZ @TipsyWisdom last edited by

                @tipsywisdom thanks for the support.
                I tried this but not working. The cross width is only for comparing the chosen candle ID with candle X in the past (cross width X). So in case there is a candle ID smaller than X which has touched the MA we won't find it and will output false results.

                1 Reply Last reply Reply Quote 0
                • Z
                  ZhAhZ @bk7 last edited by

                  @bk7 thanks for the reply.
                  I tried to realize this but couldn't understand some parts. up-counter and dn-counter I have no idea why they are there. Plus how the loop connects to buy or sell.

                  Would you please also mention what is wrong with my logic? thanks.

                  bk7 1 Reply Last reply Reply Quote 0
                  • bk7
                    bk7 @ZhAhZ last edited by

                    @zhahz

                    1. i didnt check your logic in detail, i just saw that this hardly will work and made for you a solution that works
                    2. up counter is the number of bars that close above the ma and dn counter vice versa (this way you just have to loop once for the upper and lower close)
                    3. in your Problem you didnt mention anyhting about buy or sell, however making such things isnt tricky at all and the forum has plenty of posts regarding this issue. If there are any advanced tasks surrounding buy and sell, you can post your problem here and someone will give you a hint
                    1 Reply Last reply Reply Quote 1
                    • jstap
                      jstap @ZhAhZ last edited by

                      @zhahz The other examples work but, I prefer to use the loop in this link: link text
                      This will reset to 0 whenever the condition is false.

                      Hope this helps

                      Learn fxDreema Without the Wait!

                      My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                      The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                      Don’t miss out

                      Click here➡️ https://mybook.to/fxDreema to get your copy today!

                      Enjoy! 😊

                      S 1 Reply Last reply Reply Quote 2
                      • Z
                        ZhAhZ last edited by

                        Thanks a lot guys, this forum is very supportive. Really appreciate that.

                        I didn't had the time to check your solutions, was busy developing a new idea which actually worked out and is very simple. The only drawback is that it won't work on the first X candle. Other than that pretty strait forward and easy, please check it, could be very useful for many different indicators:

                        https://fxdreema.com/shared/sby3PO6xd

                        1 Reply Last reply Reply Quote 1
                        • J
                          Jhell last edited by

                          Just click nd drag the condition block

                          1 Reply Last reply Reply Quote 0
                          • S
                            s00071609 @jstap last edited by

                            @jstap Its a great way to get number of bars - thanks for the idea. However I wanted to ask if you ever experienced stack overflow error with several of these loops running per tick?

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

                              I have not, chat gbp might know an answer

                              Learn fxDreema Without the Wait!

                              My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                              The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                              Don’t miss out

                              Click here➡️ https://mybook.to/fxDreema to get your copy today!

                              Enjoy! 😊

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

                              Online Users

                              B
                              A
                              J
                              D
                              E

                              16
                              Online

                              146.7k
                              Users

                              22.4k
                              Topics

                              122.6k
                              Posts

                              Powered by NodeBB Forums | Contributors