Try this code. It has been working for me. It does HLC of the previous day and seems to work on all instruments.
Code:
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = yes;
plot PrevDayHigh;
plot PrevDayLow;
plot PrevDayClose;
if showOnlyLastPeriod and !IsNaN(high(period = aggregationPeriod)[-1]) and !IsNaN(low(period = aggregationPeriod)[-1]) and !IsNaN(close(period = aggregationPeriod)[-1])
{
PrevDayHigh = Double.NaN;
PrevDayLow = Double.NaN;
PrevDayClose = Double.NaN;
}
else
{
PrevDayHigh = Highest(high(period = aggregationPeriod)[-displace], length);
PrevDayLow = Highest(low(period = aggregationPeriod)[-displace], length);
PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);
}
PrevDayHigh.SetDefaultColor(CreateColor(0,255,255));
PrevDayHigh.SetPaintingStrategy(PaintingStrategy.LINE);
PrevDayLow.SetDefaultColor(CreateColor(0,255,255));
PrevDayLow.SetPaintingStrategy(PaintingStrategy.LINE);
PrevDayClose.SetDefaultColor(CreateColor(116,189,239));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.LINE);
PrevDayClose.SetStyle(Curve.LONG_DASH);