#VolumeProfile_Choice_of_Displaying_Input_Dates_Times
#Dates and Times must show on chart
#
input startdate = 20250715;
input enddate = 20250717;
input starttime = 1000;
input endtime = 0900;
input show_profilehigh_low = yes;
#Show vol profile will display the profile area when set to yes. However, since we have no control over the function vol.show, the profile for the area beyond the selected dates/times will also display. Therefore the default is set to no.
input show_vol_profile = no;
input show_label = yes;
AddLabel(show_label, "VolProfile: " + AsPrice(startdate) + " at " + AsPrice(starttime) + " to " + AsPrice(enddate) + " at " + AsPrice(endtime), Color.YELLOW);
input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input onExpansion = no;
input profiles = 2;
input showPointOfControl = yes;
input showValueArea = no;
input valueAreaPercent = 70;
input opacity = 50;
def na = Double.NaN;
def tz = CompoundValue(1, if GetYYYYMMDD() == startdate and GetYYYYMMDD() <= enddate and SecondsFromTime(starttime) == 0 then 1 else if tz[1] == 1 and GetYYYYMMDD() < enddate then 1 else if tz[1] == 1 and GetYYYYMMDD() == enddate and SecondsFromTime(endtime) <= 0 then 1 else 0, 0);
def zone = 1;
def cond = tz != tz[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" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def pc = if IsNaN(vol.GetPointOfControl()) then pc[1] else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) then hVA[1] else vol.GetHighestValueArea();
def lVA = if IsNaN(vol.GetLowestValueArea()) then lVA[1] else vol.GetLowestValueArea();
def hProfile = if IsNaN(vol.GetHighest()) then hProfile[1] else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) then lProfile[1] else vol.GetLowest();
def POC_ = if tz == zone then pc else na;
def ProfileHigh_ = if tz == zone then hProfile else na;
def ProfileLow_ = if tz == zone then lProfile else na;
def VAHigh_ = if tz == zone then hVA else na;
def VALow_ = if tz == zone then lVA else na;
plot POC = POC_;
plot VAHigh = VAHigh_;
plot VALow = VALow_;
plot ProfileHigh = if !show_profilehigh_low then na else ProfileHigh_;
plot ProfileLow = if !show_profilehigh_low then na else ProfileLow_;
DefineGlobalColor("Profile", Color.GRAY);
DefineGlobalColor("Point Of Control", Color.RED);
DefineGlobalColor("Value Area", Color.GRAY);
vol.Show(if show_vol_profile then GlobalColor("Profile") else Color.CURRENT);#, if showPointOfControl then GlobalColor("Point Of Control") else Color.CURRENT, if showValueArea then GlobalColor("Value Area") else Color.CURRENT, opacity);
POC.SetDefaultColor(GlobalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(GlobalColor("Value Area"));
VALow.SetDefaultColor(GlobalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
input bubbles = yes;
input n = 6;
AddChartBubble(bubbles and tz[n] == 1 and tz[n - 1] == 0, VAHigh[n], "VAH", Color.YELLOW, yes);
AddChartBubble(bubbles and tz[n] == 1 and tz[n - 1] == 0, VALow[n], "VAL", Color.YELLOW, no);
AddChartBubble(bubbles and tz[n] == 1 and tz[n - 1] == 0, POC[n], "POC", Color.RED, no);
#