I am really struggling to understand when events happen in this system. I am trying to implement a basic algo that operates as follows

1. 20 min before close (Using scheduled event fired 20min before the close) buy 100 shares.

2. After the close that day calculate the Stop and Target for next day(Using scheduled event)

In the logs there are several time stamps, one driven by the Debug command and one from my printing the Time of the slice I am accessing. These times do not line up in any manner, I see info from the day before printed after the infor triggered by the endofDay scheduled event.

Is there a good example of managing time in the algorithms?