fxDreema

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

    Avoid Weekends and Holidays

    Questions & Answers
    3
    5
    1234
    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
      john 5 last edited by

      Hi, I would like to enter a position on the specified date every year (bar open or closed or specified hour). However for some years that date is a business day and for some other years it is a weekend or holiday. Therefore, I was wandering how we could create a condition that would place a trade on the next available (so first next or second next etc. ) trading day in the case where on the pre-selected day the market is closed ? For example: IF on day X the market is closed shift the entry to the day X+1 . I would appreciate any ideas, thank you !

      1 Reply Last reply Reply Quote 0
      • D
        DGRL last edited by

        Does your broker allows you to place orders when market is closed?
        I might not fully understand what you mean i guess

        1 Reply Last reply Reply Quote 0
        • F
          fxzen last edited by

          You could do condition on Market properties, time. Then do Value > Time > Components and select for that day.

          Then do a "Time filter" based on weekday, if it ends up being a weekday, do a formula that does a N+1 (counter)

          Then you can have another block can check for this N+1 value and if it's present, it tries to place the trade. If it's successful placing the trade, reset the variable back to 0.

          This won't handle the holidays, but without looking at external feeds (at least in MT4) I'm not sure of a way do to this without just manually programming in the holidays for every one that happens, for every year.

          The only other idea is that if your broker disables your connection during weekends/holidays, you could also use the "Terminal Connected" block. Holidays can also be tricky depending on instrument. For example, some holidays only Asian indexes are closed, while on others only American indexes are closed.

          1 Reply Last reply Reply Quote 0
          • J
            john 5 last edited by

            Thanks very much for the insights. I might use those trick for the other occasion too. This time I figured that we can code a condition(s) for particular order with a time filter that specify the day of interest x. Then we can create 5 copies of that condition with the time filter where for each copy a time filter is set to x+n (n=1,..,5; where n is a copy). If we set up a trade duration longer than 5 days (am planning minimum two weeks) and make sure that any x+n copy will be activated only if there is no trade then the EA will always look to place a trade during one of the next 5 days. In practice this will take care of any day during which the market is closed even if we have holidays right before or after the weekend.The solution does not seem to be elegant due to a compulsive copy&paste action and could probably make a use of a loop but am not there yet ;

            1 Reply Last reply Reply Quote 0
            • F
              fxzen last edited by

              For sure, the best approach is the one that works and that you understand, and that sounds good to me.

              Simple and understandable trumps elegance.

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

              Online Users

              E
              H
              E
              S
              A
              T
              A
              A
              M
              A
              M
              E
              E
              F

              25
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors