Print(
DateTime.Today.ToString("yyyy-MM-dd") + "," +
TradingHours.GetPreviousTradingDayEnd(Time[0]).Date.ToString("yyyy-MM-dd") + "," +
PriorDayOHLC().PriorOpen[0].ToString() + "," +
PriorDayOHLC().PriorHigh[0].ToString() + "," +
PriorDayOHLC().PriorLow[0].ToString() + "," +
PriorDayOHLC().PriorClose[0].ToString()
);
2022-11-05,2022-11-03,3777.25,3782.5,3704.25,3728.25
As I am running this on Saturday, 2022-11-05, the previous trading day should be Friday, 2022-11-04 instead of the returned date of 2022-11-03. Also, the OHLC prices that are returned are incorrect for 2022-11-04 and for 2022-11-03. According to CME, the OHLC prices for those dates are
2022-11-04, 3724.00, 3805.50, 3711.00, 3772.75
2022-11-03, 3766.75, 3782.50, 3704.25, 3727.75
My questions are
- Why is this statement returning an incorrect date for the previous trading day's end?
- What do the returned OHLC prices correspond to?
- How do I obtain the correct date of the previous session's end day?
- How do I obtain the correct OHLC prices for the previous session?

Comment