You can look into the plotPriceProfile function in profile.c. It is normally used for plotting a trade profile, but you can of course also use it for a midnight profile.