#VolumeProfile break at trading zones_Choices_of_Displaying_Zones
input zones_display = {all, default zone1_only, zone2_only, zone3_only};
input show_profilehigh_low = yes;
input extend_lines = yes;
input zone1_begin = 0400;
input zone2_begin = 0929;
input zone3_begin = 1600;
input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input onExpansion = no;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 20;
def na = Double.NaN;
def tz = if SecondsFromTime(zone1_begin) >= 0 and SecondsFromTime(zone2_begin) < 0 then 1
else if SecondsFromTime(zone2_begin) >= 0 and SecondsFromTime(zone3_begin) < 0 then 2
else if SecondsFromTime(zone3_begin) >= 0 then 3 else tz[1];
def zone;
switch (zones_display) {
case zone1_only:
zone = 1;
case zone2_only:
zone = 2;
case zone3_only:
zone = 3;
case all:
zone = Double.NaN;
}
input show_label = yes;
AddLabel(show_label, (if IsNaN(zone) then "VolumeProfile Displaying ALL Zones" else "VolumeProfile Displaying Only Zone == " + zone) + (if zone and extend_lines then ", Extended" else ""), Color.YELLOW);
AddLabel(show_label and show_profilehigh_low, "Profiles High/Low Displayed", Color.WHITE);
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 con = CompoundValue(1, onExpansion, 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 = IsNaN(close) == onExpansion;
def POC_ = if if IsNaN(zone) then plotsDomain
else plotsDomain and tz == zone then pc
else if !extend_lines then na
else POC_[1];
def ProfileHigh_ = if if IsNaN(zone) then plotsDomain
else plotsDomain and tz == zone then hProfile
else if !extend_lines then na
else ProfileHigh_[1];
def ProfileLow_ = if if IsNaN(zone) then plotsDomain
else plotsDomain and tz == zone then lProfile
else if !extend_lines then na
else ProfileLow_[1];
def VAHigh_ = if if IsNaN(zone) then plotsDomain
else plotsDomain and tz == zone then hVA
else if !extend_lines then na
else VAHigh_[1];
def VALow_ = if if IsNaN(zone) then plotsDomain
else plotsDomain and tz == zone then lVA
else if !extend_lines then na
else VALow_[1];
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", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));
#vol.Show(#GlobalColor("Profile")
#color.gray, 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 = 2;
def n1 = n + 1;
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VAHigh[n1], "VAH", color = Color.YELLOW, yes);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VALow[n1], "VAL", Color.YELLOW, no);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), POC[n1], "POC", Color.RED, no);
#