Volume Zone Oscillator & Price Zone Oscillator

H

henry1224

Member
VIP
Here is a binary indicator that shows 5 MTF of the Price Zone Oscillator on top and a Volume Zone Oscillator on the bottom. Green bullish, Red Bearish, lower time frame on the bottom Higher time frame on top

Here is the code

Code:
##########################
Declare Lower;
# GLOBAL DEFINITIONS

DefineGlobalColor("TrendUp", CreateColor(0, 254, 30));
DefineGlobalColor("TrendDown", CreateColor(255, 3, 2));

input agg = AggregationPeriod.FIVE_MIN;
input agg2 = AggregationPeriod.THIRTY_MIN;
input agg3 = AggregationPeriod.HOUR;
input agg4 = AggregationPeriod.TWO_Hours;;
input agg5 = AggregationPeriod.FOUR_HOURs;
input DotSize = 5;
input n = 11;
def n1  = n + 1;
input length = 14;

#Aggregation 1
def V = Volume(Period = AGG);
def C = Close(Period =AGG);
def VP = ExpAverage(Sign(C - C[1]) * V, length);
def TV = ExpAverage(V, length);
def VZO = 100 * VP / TV;
plot VZO_Dot = if IsNaN(c) then Double.NaN else 1;
VZO_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
VZO_Dot.SetLineWeight(DotSize);
VZO_Dot.AssignValueColor(if 0 > VZO then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c [n1]) and IsNaN(C [n]), 1, (agg/1000/60) + " min", Color.Yellow, yes);

#Aggregation 2
def V2 = Volume(Period = AGG2);
def C2 = Close(Period =AGG2);
def VP2 = ExpAverage(Sign(C2 – C2[1]) * V2, length);
def TV2 = ExpAverage(V2, length);
def VZO2 = 100 * VP2 / TV2;
plot VZO2_Dot = if IsNaN(c2) then Double.NaN else 2;
VZO2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
VZO2_Dot.SetLineWeight(DotSize);
VZO2_Dot.AssignValueColor(if 0 > VZO2 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c2 [n1]) and IsNaN(C2 [n]), 2, (agg2/1000/60) + " min", Color.Yellow, yes);
#Aggregation 3
def V3 = Volume(Period = AGG3);
def C3 = Close(Period =AGG3);
def VP3 = ExpAverage(Sign(C3 – C3[1]) * V3, length);
def TV3 = ExpAverage(V3, length);
def VZO3 = 100 * VP3 / TV3;
plot VZO3_Dot = if IsNaN(c3) then Double.NaN else 3;
VZO3_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
VZO3_Dot.SetLineWeight(DotSize);
VZO3_Dot.AssignValueColor(if 0 > VZO3 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c3 [n1]) and IsNaN(C3 [n]), 3, (agg3/1000/60) + " min", Color.Yellow, yes);
#Aggregation 4
def V4 = Volume(Period = AGG4);
def C4 = Close(Period =AGG4);
def VP4 = ExpAverage(Sign(C4 – C4[1]) * V4, length);
def TV4 = ExpAverage(V4, length);
def VZO4 = 100 * VP4 / TV4;
plot VZO4_Dot = if IsNaN(c4) then Double.NaN else 4;
VZO4_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
VZO4_Dot.SetLineWeight(DotSize);
VZO4_Dot.AssignValueColor(if 0 > VZO4 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c4 [n1]) and IsNaN(C4 [n]), 4, (agg4/1000/60) + " min", Color.Yellow, yes);
#Aggregation 5
def V5 = Volume(Period = AGG5);
def C5 = Close(Period =AGG5);
def VP5 = ExpAverage(Sign(C5 – C5[1]) * V5, length);
def TV5 = ExpAverage(V5, length);
def VZO5 = 100 * VP5 / TV5;
plot VZO5_Dot = if IsNaN(c5) then Double.NaN else 5;
VZO5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
VZO5_Dot.SetLineWeight(DotSize);
VZO5_Dot.AssignValueColor(if 0 > VZO5 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c5 [n1]) and IsNaN(C5 [n]), 5, (agg5/1000/60) + " min", Color.Yellow, yes);

#Aggregation 1
def CP = ExpAverage(Sign(C - C[1]) * C, length);
def TC = ExpAverage(C, length);
def PZO = 100 * CP / TC;
plot PZO_Dot = if IsNaN(c) then Double.NaN else 7;
PZO_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
PZO_Dot.SetLineWeight(DotSize);
PZO_Dot.AssignValueColor(if 0 > PZO then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c [n1]) and IsNaN(C [n]), 7, (agg/1000/60) + " min", Color.Yellow, yes);

#Aggregation 2
def CP2 = ExpAverage(Sign(C2 – C2[1]) * C2, length);
def TC2 = ExpAverage(C2, length);
def PZO2 = 100 * CP2 / TC2;
plot PZO2_Dot = if IsNaN(c2) then Double.NaN else 8;
PZO2_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
PZO2_Dot.SetLineWeight(DotSize);
PZO2_Dot.AssignValueColor(if 0 > PZO2 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c2 [n1]) and IsNaN(C2 [n]), 8, (agg2/1000/60) + " min", Color.Yellow, yes);
#Aggregation 3
def CP3 = ExpAverage(Sign(C3 – C3[1]) * C3, length);
def TC3 = ExpAverage(C3, length);
def PZO3 = 100 * CP3 / TC3;
plot PZO3_Dot = if IsNaN(c3) then Double.NaN else 9;
PZO3_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
PZO3_Dot.SetLineWeight(DotSize);
PZO3_Dot.AssignValueColor(if 0 > PZO3 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c3 [n1]) and IsNaN(C3 [n]), 9, (agg3/1000/60) + " min", Color.Yellow, yes);
#Aggregation 4
def CP4 = ExpAverage(Sign(C4 – C4[1]) * C4, length);
def TC4 = ExpAverage(C4, length);
def PZO4 = 100 * CP4 / TC4;
plot PZO4_Dot = if IsNaN(c4) then Double.NaN else 10;
PZO4_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
PZO4_Dot.SetLineWeight(DotSize);
PZO4_Dot.AssignValueColor(if 0 > PZO4 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c4 [n1]) and IsNaN(C4 [n]), 10, (agg4/1000/60) + " min", Color.Yellow, yes);
#Aggregation 5
def CP5 = ExpAverage(Sign(C5 – C5[1]) * C5, length);
def TC5 = ExpAverage(C5, length);
def PZO5 = 100 * CP5 / TC5;
plot PZO5_Dot = if IsNaN(c5) then Double.NaN else 11;
PZO5_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
PZO5_Dot.SetLineWeight(DotSize);
PZO5_Dot.AssignValueColor(if 0 > PZO5 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c5 [n1]) and IsNaN(C5 [n]), 11, (agg5/1000/60) + " min", Color.Yellow, yes);
 
Top