fxDreema

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

    Last tick of the day?

    Questions & Answers
    2
    6
    1401
    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
      mikemindel last edited by mikemindel

      Thanks for fxDreema. Really enjoying using it.

      Q: How do I detect the last tick of the day so I can close out all my trades?

      Reason I'm asking is that I'm trading during specific hours e.g. 7am - 8pm. However, using Tick Data Manager I'm finding some of the historical tick data ends at 5pm/6pm. And so the EA ends up rolling over into the following morning at 7am.

      I thought maybe using a Candle ID of -1 to detect the time of the next tick and compare the time with the previous tick might do it. Then I can close out all the trades on the current tick, which would be the last tick of the day.

      Please let me know if it's possible. Thx.

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

        For Candle ID use positive values. 1 instead of -1. Candle's Close time at Candle ID = 1 should be the last data available

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

          Thanks, however it doesn't solve my exact issue.

          What is happening is that there is a task at 8pm to close all the trades. However the ticks do not get to 8pm, they stop at 6pm (not enough data available for that date). And then the next tick is 7am in the morning. So all the trades end up continuing into the next day. They do not get closed at 8pm because there is no tick data to get to 8pm.

          So how do I detect at 6pm (when the data runs out) that the NEXT tick will be at 7am so I can close my trades out at 6pm? Does that make sense?

          -Mike

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

            Or at least is there a way to say we are now at the end of the day, the last tick/candle of the current day?

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

              The simplest solution I can think of is a way to look "ahead" and see what the data for the next tick will be. That's why I mentioned using -1 for the candle to mean look forwards to the next candle in the future.

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

                In MQL4 there are holes in the history data, this is not unexpected. But if some EA works on real, at least then ticks should come. So you can just skip this situation. In fact, if the EA does not receive any ticks from the broker, this probably means that something is wrong anyway - markets are closed, network connection is broken or something else - so even if you force the trades to be closed, it will probably not happen. Because you can always put some blocks under "on Timer" and this event does not care if there are ticks or not. Well, "on Timer" don't work very well in the Tester, if it works at all. But anyway, if with "on Timer" you force the EA to close everything at 08:00 and the markets are closed at that time... then what is the point.

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

                Online Users

                H
                E
                A
                G
                Q
                C
                T

                21
                Online

                146.7k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors