I've been trying to plot the previous day 1600 hour candle close. It seems like it should be something simple, but I've really been struggling. Any help would be greatly appreciated.
Here is the code I thought seemed to be close, but it still gives me the 1659 candle close.
Here is the code I thought seemed to be close, but it still gives me the 1659 candle close.
Code:
declare upper;
declare hide_on_daily;
input closeTime = 1600; # 4:00 PM ET
input showLine = yes;
input lineColor = Color.ORANGE;
input lineWeight = 2;
# Check if current bar is at 16:00
def isCloseTime = SecondsFromTime(closeTime) == 0 and SecondsTillTime(closeTime) == 0;
# Get previous day's 16:00 close
def prevDayClose = if isCloseTime[1] then close[1] else prevDayClose[1];
plot PrevCloseLine = if showLine then prevDayClose else Double.NaN;
PrevCloseLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevCloseLine.SetDefaultColor(lineColor);
PrevCloseLine.SetLineWeight(lineWeight);
PrevCloseLine.SetStyle(Curve.FIRM);
# Optional: Add a label to display the value
AddLabel(yes, "Prev Day Close (16:00): " + prevDayClose, lineColor);
Last edited: