Tomorrow's date

Viewing 15 posts - 16 through 30 (of 30 total)
  • #95011

    You’re the best! I am having trouble getting the GetDayOfWeek to work, however. It is returning 2 (Tuesday) for 20190329. Any ideas?

    #95105

    I’m still working on it, to check calculations.

    #95255

    Hey, any luck?

    #95256

    Not yet, I’m trying to write a new algorithm.

    In the meantime you can use OpenDayOfWeek (or DayOfweek if you prefer the DoW at the closure of the candlestick), which works finely. Mine was just a replacement.

     

    #95257

    Dayofweek and opendayofweek do not permit input into the function so I don’t think I use them on ‘future’ dates (only present and past). This is the only thing left to solve, I believe.

    #95258

    I’ll post the code as soon as I have a correct version.

    #95272

    This version works fine after Jan. 31st, 2011:

    I tried to use several different methods, but couldn’t find any perfect one, each method turned out to have some faults. This is the most reliable I could write.

     

    #95305

    Excellent – thank you very much. Is there a reason we have the plus one before the return statement? It produces values: Monday == 2 to Friday == 6 on my end (maybe because I’m in US EST time zone?)

    Anyways, I removed the plus one and get values 1-5. Thank you for this!

    #95317

    No reason for +1, I just added it to test what I liked most and forgot to remove it (0-6 is the most common used range).

    This morning I tried another slightly different version and still got the same discrepancies:

    • up to some date in 2006 everything works in a different way and I get plenty wrong results
    • from there on till Jan.2011 the function returns almost always correct results but on some rare occasion sunday (not the other days) is reported incorrectly

    from the end of January 2011 everything works fine. I’m giving up!

    Have a good day.

     

    #95318

     

    So I tried putting together the code to retrieve the trading (business) days left in the month, but it appears to still be counting weekends. Not sure where/what I am missing?

     

    #95329

    up to some date in 2006 everything works in a different way and I get plenty wrong results

    If you check the chart in this post here you can see that the number of candles/bars in any year varies wildly.

    https://www.prorealcode.com/topic/how-many-bars-in-a-year-indicator/#post-95091

    I can understand some reasons such as the switch from 5 candle weeks to 6 candle weeks and leap years and varying holidays each year and special events that lead to market closures but it appears to me that more is going on than just this. I have the feeling that some of the back test data is not very clean!

    #95331

    If you just put this simple indicator on a daily DJI chart it can clearly be seen when the switch to 6 bar weeks happened but prior to this there are also clearly some odd things in the data.

     

    Screenshot_1

    #95337

    I tried to GRAPH all individual elements from July 1979 (how come Eur/usd is quoted since then, but had only been approved on Jan, 1st 1999, 20 years later?!), Day, Month, Year separately and everything is fine, also, DayOfWeek matches the one calculated by eXcel.

    I tried several different formulas and ALL of them reported some kind of error. They cannot be ALL erroneous!!!

    I must assume that either:

    1. I did not fully understand the logic behind those formulas (likely to be the main reason)
    2. PRT use a different way of dealing with integers; actually PRT does support only floating point numbers, so even “i” in a FOR…NEXT iteration is not an integer. This may lead to some unwanted decimal digits being used or dropped when rounding or using MOD. They don’t need much integers for trading, so many basic features found in other programming languages are missing and this may lead to errors when doing some conversions.

    But, since from Jan. 17th 2011 the code works fine, well… that’s enough for most cases!

     

    #95342

    dburgh, I changed a bit your code to make it easier to calculate the remaining business days:

    I also replaced DATE with OPENDATE, since the first one is the date when a candle closes, while the latter when it opens.

    In the first case both THURSDAY and FRIDAY report 5, since at the end of the closing daily Thursday candle the date is actually Friday, which is 5, when the next candle closes trading is stopped, so the DayOfWeek is not updated and it will still be 5 also on Friday. OPENDATE works fine.

    Moreover, line 8 should start looping from “d”, not from 1.

     

     

    #95347

    Beautiful! Thank you v much

Viewing 15 posts - 16 through 30 (of 30 total)

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