The outcommented line in your acript, StartWeek=10000, should exclude Sunday. Otherwise I suppose that Sunday, not Friday, is the day with offset 1, since the trading week begins on Sunday 22:00 UTC.

Do you get Friday when you include that line?