The solution is probably much simpler than you realize. The data is already there. All you have to do insert the mathematical formula to compute the mid point of the range.
Which is basically like this:
DailyLow + (DailyHigh - DailyLow) / 2
Here is the full solution, which has been adapted from the source code you provided:
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
plot DailyHigh;
plot DailyLow;
plot midpoint;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
DailyHigh = Double.NaN;
DailyLow = Double.NaN;
midpoint = Double.NaN;
} else {
DailyHigh = Highest(high(period = aggregationPeriod)[-displace], length);
DailyLow = Lowest(low(period = aggregationPeriod)[-displace], length);
midPoint = DailyLow + (DailyHigh - DailyLow) / 2;
}
DailyHigh.SetDefaultColor(GetColor(4));
DailyHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailyLow.SetDefaultColor(GetColor(4));
DailyLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
midpoint.SetDefaultColor(GetColor(4));
midpoint.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);