How to avoid bank holidays in trading system?

Forums ProRealTime English forum ProOrder support How to avoid bank holidays in trading system?

Viewing 15 posts - 1 through 15 (of 15 total)
  • #75375
    EB

    Hi,

    Could somebody provide me some code how to easily avoid trading during bank holidays?

    Thank you in advance!

    #75378

    If it is a bank holiday and the market is closed then no candles are produced and you can not trade a candle that does not exist! Try to find a candle for a Christmas day to prove it to yourself.

    #75392
    EB

    Yes I know, but for instance if there is a bank holiday in US, the DAX may still be running. That may have an effect on the DAX once the US starts to open again the next day.

    #75394

    Beyond noting the date of each bank holiday that you want to avoid and then including it in a IF THEN condition within or surrounding your strategy I can not think of another way to do what you want. Creating a back test to prove whether this is worth doing would be quite labour intensive.

    #75395
    EB

    Can you give me an example of such code?

    #75398

     

    1 user thanked author for this post.
    avatar EB
    #75399

    I guess that if there is a holiday that is on exactly the same date every year then you could do this:

    You could also I guess code something to work out if the fixed date falls on a weekend and then move it to the Monday but I will leave that one to you as I’m not sure that the effort is worth the benefit. 🙂

    1 user thanked author for this post.
    avatar EB
    #75415

    You can find the day of the week number with this code snippet:

    Replace myYear,myMonth and myDay with YYYY, MM, DD number format. In this example it basically returns the day of the week of the current day.

    3 users thanked author for this post.
    #75424

    Isn’t that what (OPEN)DAYOFWEEK does?

    #75428

    @robertogozzi

    Yes, but how do you know what opendayofweek was the 12th September 2002? This is the purpose of this snippet.

    #75429

    Isn’t that what (OPEN)DAYOFWEEK does?

    Yes – but it isn’t such a good party trick. Memorise the above calculation and amaze your friends at every party by telling them what day of the week any date in history was!

    #75432

    What use is knowing what day of the week was July 4th (for Usa) or June 2nd (for Italy) or Christmas?

    It was a Holiday for sure, this year, last year as well as many years ago!

    So, once you hard code a holiday in your strategy, that’s all

    In some countries, mostly christian/latin countries, Easter is a holiday AND it always occur on a sunday. In these countries (Italy, Spain, France…) the day following Easter (Monday) is a holiday, but since Easter is a mobile holiday you have to calculate it to know the following day will be a holiday. To calculate Easter, you can find formulas over the internet.

    That’s what I meant, any calculation is  necessary only for mobile holidays.


    @nicolas
    thanks to that snippet I know I was born on a Sunday… many… many seasons ago!

     

    #75433

    In the UK bank holidays are always on a Monday. So for example there is always a bank holiday on the first Monday in May. In 2019 this will be on the 6th May. So if the OP wants to avoid trading on those days in other markets that are still open then he will need to calculate the first Monday in May every year. I think there are four bank holidays like this each year.

    Easter in Greece is rarely the same as Easter in other countries as it is calculated using a different calender – but then I guess the Greek Easter will have little effect on markets. 🙂

    #75435

    Got it. Thanks!

    #206935

    [Old but just adding another way, if anyone interested]

    The other way would be download the “CSV” of dates & times of holidays from any public government database, this would already be formatted in the tidy data style that aligns with PRT date and time formats, so just need to copy+paste it into your strategies code [For PRT people they have API’s for updating in real-time, if ever consider implementing holidays as function within PRT].

    Most governments provide these on some public database site, for example data.gov.au for Australia would show all the full and half-day trading holidays for the upcoming years.

    And regarding this using the earlier methods:

    You could also I guess code something to work out if the fixed date falls on a weekend and then move it to the Monday

    I assume something like this would work to move the holiday to the Monday or Friday:

    2 users thanked author for this post.
Viewing 15 posts - 1 through 15 (of 15 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login