fxDreema

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

    On bar close, do this...

    Questions & Answers
    2
    7
    1456
    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
      james last edited by

      Hello 🙂

      I'd be very grateful for a little help.

      I'm attempting to capture the time a bar closes, thus:

      __on the close of the current bar, send the time to PrevBarClose (a variable)[/quote:33ol25al]
      Or possibly:

      __on the open of a new bar, send the time of the closure of the previous bar to PrevBarClose[/quote:33ol25al]
      I've been messing around with all sorts of methods, none of which worked. So I don't even have anything to share which is meaningful!

      Thanks again,

      James.

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

        ...sorry - forgot.

        I also need to have the time recorded in human readable format!

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

          Is this recording the close of the previous candle?

          https://fxdreema.com/shared/pJGmkJpGc

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

            Yes, this is. The variable should be integer (whole number), but it will work that way as well. Well, it's "datetime", which is integer.
            So, the time is integer, a whole number. Check this one: http://www.epochconverter.com/

            Here is a function to convert that time into human readable text (string), but this is for visualisations only, don't use it for calculations: http://docs.mql4.com/convert/timetostring

            And there are functions to get hour, day, second... whatever from that time value: http://docs.mql4.com/dateandtime/timehour

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

              Great! Thank you.

              Now, however, a further query - sorry!

              In the updated example here, https://fxdreema.com/shared/3GOCLH61b, I've captured the time of the last daily bar's close, but want to execute a Once a Day block in a 15 minute window, beginning 23hrs 45mins later.

              But dropping the variables "LastCandleCloseTimePlus23hrs45min" and "LastCandleCloseTimePlus24hrs" into the Start and End Hour boxes doesn't seem to work for the block.

              Suggestions will be most gratefully received! 🙂

              Thanks, as always,

              James.

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

                Again, the time is a whole number value, which is the number of seconds since 1.1.1970. It's not hours, not days, not months... it is seconds, and it is some very big number.

                I don't understand what are you trying to do, it looks for me that you are trying to do something simple in the hardest way 😕 Why not just use normal human readable hour values. The time of Daily Candle[1] is 0:00 of the previous day and when you add 86400 the result is 0:00 today. Why doing this... In places where you can see default value like 01:00, 08:00 or similar, and there is no day defined, the current day is used. Like in "Once per bar".

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

                  My apologies. I used the daily candle to try to keep things easy, but all I did was to confuse! Sorry.

                  I'm trying to achieve this:
                  __
                  *

                  • when a new bar opens, send the time of the closure of the previous bar to a variable
                  • place this value into a once per day block, so that the blocks attached to it can only execute within a 15 minute interval
                    [/list:u:14101pd8]
                    [/quote:14101pd8]
                    With your kind help, I've got as far as placing the time of the closure of the previous bar into a variable correctly.

                  The next bit is eluding me. I just can't work it out! 🙂

                  It seems to me that I need to come up with a magic way of extracting from the unix time, a value in "hh:mm" format, place it in a new variable, and drop this into the "from" and "to" fields of the once per day block. Sadly, my magic isn't strong enough (indeed, its pretty weak!) to come up with the method. I appreciate I may need to use a Custom MQL4 Code block along the way to achieve this.

                  Any suggestions would be most welcome!

                  Thanks again,

                  James.

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

                  Online Users

                  A
                  L
                  S

                  13
                  Online

                  146.7k
                  Users

                  22.4k
                  Topics

                  122.6k
                  Posts

                  Powered by NodeBB Forums | Contributors