# The Pivot Points Indicator Package
# Floor Trader’s Pivot Points
# Fibonacci Pivot Point
# What we have taken the original version which only calculates R1, R2, R3 and S1, S2, S3 and have added the following features:
# Additional Support/Resistance Levels of S4 and R4
# Option to Display Mid-Pivots
# Text Labels are Plotted Adjacent to Each Level for Quick Identification
# Visual and Audio Alerts for when Price Crosses any of the S/R Levels
input marketThreshold = 0.00;
input timeFrame = AggregationPeriod.DAY;
Input MidPlot = yes;
input showOnlyToday = no;
input showBubble = yes;
input ShiftBubble = 5;def n1 = ShiftBubble+1;
def PP2 = high(period = timeFrame)[2] + low(period = timeFrame)[2] + close(period = timeFrame)[2];
plot R4;
plot R3;
plot Mid3;
plot R2;
plot Mid2;
plot R1;
plot Mid1;
plot PP;
plot Mid_1;
plot S1;
plot Mid_2;
plot S2;
plot Mid_3;
plot S3;
plot S4;
if showOnlyToday and !IsNaN(close(period = timeFrame)[-1])
then {
R1 = Double.NaN;
R2 = Double.NaN;
R3 = Double.NaN;
R4 = Double.NaN;
PP = Double.NaN;
S1 = Double.NaN;
S2 = Double.NaN;
S3 = Double.NaN;
S4 = Double.NaN;
Mid1 = Double.NaN;
Mid2 = Double.NaN;
Mid3 = Double.NaN;
Mid_1 = Double.NaN;
Mid_2 = Double.NaN;
Mid_3 = Double.NaN;
} else {
PP = (high(period = timeFrame)[1] + low(period = timeFrame)[1] + close(period = timeFrame)[1]) / 3;
#
R1 = 2 * PP - low(period = timeFrame)[1];
S1 = 2 * PP - high(period = timeFrame)[1];
#
MID1 = PP + ((R1 - PP) /2);
MID_1 = PP - ((PP - S1) /2);
#
R2 = PP + (High(period = timeFrame)[1] - Low(period = timeFrame) [1]);
S2 = PP - (High(period = timeFrame) [1] - Low(period = timeFrame) [1]);
#
MID2 = R1 + ((R2 - R1) /2);
MID_2 = S1 - ((S1 - S2) /2);
#
R3 = R2 + high(period = timeFrame)[1] - low(period = timeFrame)[1];
S3 = S2 - high(period = timeFrame)[1] + low(period = timeFrame)[1];
#
MID3 = R2 + ((R3 - R2) /2);
MID_3 = S2 - ((S2 - S3) /2);
#
R4 = R3 + high(period = timeFrame)[1] - low(period = timeFrame)[1];
S4 = S3 - high(period = timeFrame)[1] + low(period = timeFrame)[1];
}
PP.SetDefaultColor(GetColor(0));
R1.SetDefaultColor(Color.Red);
R2.SetDefaultColor(Color.Red);
R3.SetDefaultColor(Color.Red);
R4.SetDefaultColor(Color.Red);
S1.SetDefaultColor(Color.Yellow);
S2.SetDefaultColor(Color.Yellow);
S3.SetDefaultColor(Color.Yellow);
S4.SetDefaultColor(Color.Yellow);
Mid1.SetDefaultColor(GetColor(3));
Mid2.SetDefaultColor(GetColor(3));
Mid3.SetDefaultColor(GetColor(3));
Mid_1.SetDefaultColor(GetColor(3));
Mid_2.SetDefaultColor(GetColor(3));
Mid_3.SetDefaultColor(GetColor(3));
PP.SetStyle(Curve.firm);
R1.SetStyle(Curve.SHORT_DASH);
R2.SetStyle(Curve.SHORT_DASH);
R3.SetStyle(Curve.SHORT_DASH);
R4.SetStyle(Curve.SHORT_DASH);
S1.SetStyle(Curve.SHORT_DASH);
S2.SetStyle(Curve.SHORT_DASH);
S3.SetStyle(Curve.SHORT_DASH);
S4.SetStyle(Curve.SHORT_DASH);
Mid1.SetStyle(Curve.SHORT_DASH);
Mid2.SetStyle(Curve.SHORT_DASH);
Mid3.SetStyle(Curve.SHORT_DASH);
Mid_1.SetStyle(Curve.SHORT_DASH);
Mid_2.SetStyle(Curve.SHORT_DASH);
Mid_3.SetStyle(Curve.SHORT_DASH);
def paintingStrategy = if timeFrame == AggregationPeriod.WEEK then PaintingStrategy.DASHES else if timeFrame == AggregationPeriod.MONTH then PaintingStrategy.DASHES else PaintingStrategy.LINE_VS_POINTS;
PP.SetPaintingStrategy(PaintingStrategy.DASHES);
R1.SetPaintingStrategy(PaintingStrategy.DASHES);
R2.SetPaintingStrategy(PaintingStrategy.DASHES);
R3.SetPaintingStrategy(PaintingStrategy.DASHES);
R4.SetPaintingStrategy(PaintingStrategy.DASHES);
S1.SetPaintingStrategy(PaintingStrategy.DASHES);
S2.SetPaintingStrategy(PaintingStrategy.DASHES);
S3.SetPaintingStrategy(PaintingStrategy.DASHES);
S4.SetPaintingStrategy(PaintingStrategy.DASHES);
Mid1.SetPaintingStrategy(PaintingStrategy.DASHES);
Mid2.SetPaintingStrategy(PaintingStrategy.DASHES);
Mid3.SetPaintingStrategy(PaintingStrategy.DASHES);
Mid_1.SetPaintingStrategy(PaintingStrategy.DASHES);
Mid_2.SetPaintingStrategy(PaintingStrategy.DASHES);
Mid_3.SetPaintingStrategy(PaintingStrategy.DASHES);
def cond = showBubble and isNaN(close[ShiftBubble]) and !isNaN(close[n1]) ;
AddChartBubble(cond,PP,Concat("PP: ",Round(PP)),color.magenta);
AddChartBubble(cond,R1,Concat("R1: ",Round(R1)),color.magenta);
AddChartBubble(cond,R2,Concat("R2: ",Round(R2)),color.magenta);
AddChartBubble(cond,R3,Concat("R3: ",Round(R3)),color.magenta);
AddChartBubble(cond,R4,Concat("R4: ",Round(R4)),color.magenta);
AddChartBubble(cond,S1,Concat("S1: ",Round(S1)),color.magenta);
AddChartBubble(cond,S2,Concat("S2: ",Round(S2)),color.magenta);
AddChartBubble(cond,S3,Concat("S3: ",Round(S3)),color.magenta);
AddChartBubble(cond,S4,Concat("S4: ",Round(S4)),color.magenta);
AddChartBubble(cond,Mid1,Concat("Mid1: ",Round(Mid1)),color.magenta);
AddChartBubble(cond,Mid2,Concat("Mid2: ",Round(Mid2)),color.magenta);
AddChartBubble(cond,Mid3,Concat("Mid3: ",Round(Mid3)),color.magenta);
AddChartBubble(cond,Mid_1,Concat("Mid_1: ",Round(Mid_1)),color.magenta);
AddChartBubble(cond,Mid_2,Concat("Mid_2: ",Round(Mid_2)),color.magenta);
AddChartBubble(cond,Mid_3,Concat("Mid_3: ",Round(Mid_3)),color.magenta);
Mid1.SetHiding (!MidPlot);
Mid2.SetHiding (!MidPlot);
Mid3.SetHiding (!MidPlot);
Mid_1.SetHiding (!MidPlot);
Mid_2.SetHiding (!MidPlot);
Mid_3.SetHiding (!MidPlot);
#####