how to get any previous open market day in YYYYMMDD format?

Forums ProRealTime English forum ProOrder support how to get any previous open market day in YYYYMMDD format?

Viewing 4 posts - 1 through 4 (of 4 total)
  • #236898

    Hello,

    let’s consider the monday 3rd of March, 2008 as a current date (= Today ) and also that the market was closed on every saturday and sunday, like on the 1st and 2nd of March, 2008.

    Is there an easy way to code a request which will return 20080229 as the previous open market day ?

    Could this also manage not only the leap years and the regular week days off (as example saturday & sunday) but also any holidays list (as example 25th of december 2023 and 1st of january 2023) ?

    Something like :

    diff=1                                                                   // parameter which gives the increment of lookback in open market days

    previousOpenMarketDay = Today – diff      // would give  : 20080303 – 1 => 20080229 ;   or   20240801 – 1 => 20240731 ;   or   20240102 – 1 => 20231229

    Many thanks

    Oli

     

     

    #236905

    Hello,

    The variable jouravant coded below would give each day what the date was at market open the previous day (beware with 24h-quoted assets like IG cfd combined with an unfortunate timezone difference between market time and local time, which would require a different coding to work for all possible cases).

    The other variable MMDDjouravant transforms it into MMDD format to check it with a drawtext avoiding the 20.2M display

     

    #236911

    The solution suggested by JC_Bywan, is far easier, but since I had already started coding an indicator, I attach it.

    This indicator will return the previous day of any date in the format YYYYMMDD:

    while JC_Bywan‘s code will always skip holidays, mine will not as it cannot know when it’s not a trading day, apart from Saturdays and Sundays.

     

    #236969

    Thanks a lot JC_Bywan and robertogozzi

    your answers help me to make my way which at the moment is:

    .setting up an array with all the days off (weekends or holidays) in YYYYMMDD  format [can be easily generated by excel / however I limited this to 2023 2024 2025]

    .checking in a loop, for each new opendate, if opendate[1] doesn’t match a date in the array. In case it does, then check again with opendate[2] and so on

Viewing 4 posts - 1 through 4 (of 4 total)

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