I am trying to make some code to return the last market close (since DClose(1) seems to return the midnight close) to calculate the rate of change since last market close in ProOrder. I think the following code should work (trying to debug it by adding it as an indicator):
marketCloseTime = 173000
marketCloseHour = 17
marketCloseMinute = 30
barLength = 3
intradayCloseBar = marketCloseHour * 60 / barLength + marketCloseMinute / barLength
intradayBars = 24 * 60 / barLength
currentBar = OpenHour * 60 / barLength + OpenMinute / barLength
IF (OpenTime >= marketCloseTime) THEN
numberOfBars = currentBar - intradayCloseBar
ELSE
numberOfBars = intradayBars - intradayCloseBar + currentBar
ENDIF
RETURN close[numberOfBars]
but it is not… It seems like the numberOfBars ends up being “fixed” when used together with close[], so the last bar of gets the close of 173000 correct, but the second last gets 172700 which is not what I want. I want all bars to return the close of the last 173000.
If I do “RETURN numberOfBars” then it correctly returns the number of bars since last 173000.
What am I missing? Or is there some easier way to get the last market close?
Thanks in advance!
/Mårten
Try this:
ONCE x = close
IF OpenTime = 173000 THEN
x = close
ENDIF
RETURN x AS "Last Daily Close"