Hey Quant Community!

I have created a simple algorithm that is just supposed to grab the previous week's high at the beginning of every week. I have also made it so that it logs the previous week's high every time spy price crosses above it. I have noticed some problems and I have no idea what is happening: 

Sometimes it will log the previous week's high on a Tuesday instead of the Monday 

The order logs seem to be a week behind. 

When comparing the numbers on TradingView, I sometimes get different answers, some just a few cents off, and some up to a few dollars. 

Can someone please tell me what I am doing wrong?

Author