fxDreema

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

    Find the highest (or lowest) close of x bars

    Questions & Answers
    3
    11
    652
    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.
    • M
      MT4Nutzer last edited by

      Hello community,

      does anybody know a way to find the highest (or lowest) close of x bars (not the highest high or the lowest low)?

      Thanks in forward and have a good week!
      Tommi

      H S 2 Replies Last reply Reply Quote 0
      • H
        Hiten7405 @MT4Nutzer last edited by

        @MT4Nutzer

        20f84a54-6921-4954-ba1c-8c02b811d4eb-image.png

        https://www.mql5.com/en/users/8541393/seller

        M 1 Reply Last reply Reply Quote 1
        • M
          MT4Nutzer @Hiten7405 last edited by

          @Hiten7405 said in Find the highest (or lowest) close of x bars:

          @MT4Nutzer

          20f84a54-6921-4954-ba1c-8c02b811d4eb-image.png

          Thank you @Hiten7405 . But I think this are the highs and lows of the last candles not the the close values.

          H 1 Reply Last reply Reply Quote 0
          • H
            Hiten7405 @MT4Nutzer last edited by

            @MT4Nutzer
            It shows the high and low price between the selected candles.

            https://www.mql5.com/en/users/8541393/seller

            1 Reply Last reply Reply Quote 1
            • S
              sktsec @MT4Nutzer last edited by sktsec

              @MT4Nutzer
              Initiate then use the loop block and a condition block.

              Suppose x is the result

              Initiate x (such as close of the start candle)
              Loop n times for the candles
              Use condition block to compare x and close
              save any new value to x

              [Amended: loop n times not x times]

              M 1 Reply Last reply Reply Quote 1
              • M
                MT4Nutzer @sktsec last edited by

                @sktsec said in Find the highest (or lowest) close of x bars:

                @MT4Nutzer
                Initiate then use the loop block and a condition block.

                Support x is the result

                Initiate x (such as close the start candle)
                Loop x time for the candles
                Use condition block to compare x and close
                save any new value to x

                Thank you @sktsec . I want to try it.

                S 1 Reply Last reply Reply Quote 1
                • S
                  sktsec @MT4Nutzer last edited by sktsec

                  @MT4Nutzer

                  Try this

                  https://fxdreema.com/shared/cKDDvcRye

                  capture_001_21012025_003318.png

                  1 Reply Last reply Reply Quote 1
                  • S
                    sktsec last edited by sktsec

                    result: The highest closest in recent nBars (including current Candle: ID0)

                    nBars : Input number of bars
                    loopID: Before the loop -1. +1 for every loop. i.e. loop start from Candle 0
                    provisionalResult: Highest close in looping process

                    1 Reply Last reply Reply Quote 1
                    • S
                      sktsec last edited by

                      So you only need 2 blocks to get your result.

                      You can customize the starting Candle ID. But remember to set the looping candle ID be startCandleID -1 before entering the loop

                      1 Reply Last reply Reply Quote 1
                      • S
                        sktsec last edited by sktsec

                        This is the case for highest. For the lowest, remember to set the initial value of the provsionalResult to a large number, say, 99999999. (of course, you would modify the condition block as well)

                        Sure you can add a block to initiate this variable to the value of starting Candle close. That is up to your preference.

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

                          Great! Thank you very much @sktsec !
                          I think it will be a long evening.

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

                          Online Users

                          D
                          A
                          K
                          K
                          E
                          S
                          I
                          G
                          F
                          A
                          I
                          E

                          23
                          Online

                          146.6k
                          Users

                          22.4k
                          Topics

                          122.6k
                          Posts

                          Powered by NodeBB Forums | Contributors