Nicholas – thanks very much indeed, that is much simpler code than the MT4 version!
One small request though, can you please show me how to make this draw only horizontal lines like the MT4 one in the screenshot, and avoid those vertical/diagonal lines between the close of one day and the open of the next? I find the verticals very distracting with other indicators I use.
EDIT: one thing I noticed is that this code works perfectly on a 1 hour timescale,but go to 30 minutes and it displays the line start at 17;30 (EST) instead of 17:00 and on 15 min timescale it displays at 17:45. This is not a problem for me as such, but I did wonder if this was an easy fix?