Thanks
@SleepyZ! I took your suggestion and just settled for the various levels. The script is working nicely for almost all custom time periods. I'm running into an issue when it comes to extended hours. For some reason, the script won't draw the time from 1800-2400. I'll use the following inputs:
start date: 20220810
end date: 20220811
start time: 1800
end time: 000
start date: 20220810
end date: 20220810
start time: 1800
end time: 1900 or 2000 or 2100 etc.
----------------------------------------
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input startDateYYYYMMDD = 20220801;
input endDateYYYYMMDD = 20220806;
input startTimeEST = 0000;
input endTimeEST = 0000;
input profiles = 2;
input showProfile = no;
input valueAreaPercent = 70;
input opacity = 20;
def fixedrange = if GetYYYYMMDD() < startDateYYYYMMDD then 3 else if GetYYYYMMDD() == startDateYYYYMMDD and SecondsTillTime(startTimeEST) > 0 then 3 else if GetYYYYMMDD() > endDateYYYYMMDD then 2 else if GetYYYYMMDD() == endDateYYYYMMDD and SecondsFromTime(endTimeEST) >= 0 then 2 else 1;
def fr = GetYYYYMMDD() < endDateYYYYMMDD or (GetYYYYMMDD() == endDateYYYYMMDD and SecondsTillTime(endTimeEST) > 0);
def period = fixedrange;
rec count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) else count[1], 0);
def cond = period != period[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, no, no);
def pc = if IsNaN(vol.GetPointOfControl()) and con then pc[1] else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();
def lVA = if IsNaN(vol.GetLowestValueArea()) and con then lVA[1] else vol.GetLowestValueArea();
def hProfile = if IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) and con then lProfile[1] else vol.GetLowest();
def plotsDomain = if showProfile then IsNaN(close) == no else IsNaN(close) == no and fr;
plot POC = if plotsDomain then pc else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;
DefineGlobalColor("Profile", GetColor(3));
vol.show(if showProfile then globalColor("Profile") else color.current, color.current, color.current, opacity);
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.Hide();
ProfileLow.Hide();