It’s because the market was closed on January 1st so the value for D1 cannot be found. If you change it to 2019-12-31 then the formula will be able to be calculated:
The script looks ok, i’ve tested it here and it works ok. One thing to note, when posting scripts please do not post a screen shot, rather copy and paste the script directly into the post, it makes it easier for us to test the code.