# Traditional Pivot Points
# Assembled by BenTen at UseThinkScript.com
# Based on the formula from https://www.tradingview.com/support/solutions/43000521824-pivot-points-standard/
input aggregationPeriod = AggregationPeriod.DAY;
def HIGHprev = high(period = aggregationPeriod)[1];
def LOWprev = low(period = aggregationPeriod)[1];
def CLOSEprev = close(period = aggregationPeriod)[1];
plot PP = (HIGHprev + LOWprev + CLOSEprev) / 3;
plot R1 = PP * 2 - LOWprev;
plot S1 = PP * 2 - HIGHprev;
plot R2 = PP + (HIGHprev - LOWprev);
plot S2 = PP - (HIGHprev - LOWprev);
plot R3 = PP * 2 + (HIGHprev - 2 * LOWprev);
plot S3 = PP * 2 - (2 * HIGHprev - LOWprev);
PP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
How can I name the text. S1, S2, S3, PP, R1, R2, R3? Thanks !!!Try the following code:
Code:# Traditional Pivot Points # Assembled by BenTen at UseThinkScript.com # Based on the formula from https://www.tradingview.com/support/solutions/43000521824-pivot-points-standard/ input aggregationPeriod = AggregationPeriod.DAY; def HIGHprev = high(period = aggregationPeriod)[1]; def LOWprev = low(period = aggregationPeriod)[1]; def CLOSEprev = close(period = aggregationPeriod)[1]; plot PP = (HIGHprev + LOWprev + CLOSEprev) / 3; plot R1 = PP * 2 - LOWprev; plot S1 = PP * 2 - HIGHprev; plot R2 = PP + (HIGHprev - LOWprev); plot S2 = PP - (HIGHprev - LOWprev); plot R3 = PP * 2 + (HIGHprev - 2 * LOWprev); plot S3 = PP * 2 - (2 * HIGHprev - LOWprev); PP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); R2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); S2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); R3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); S3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
How can I name the text. S1, S2, S3, PP, R1, R2, R3? Thanks !!!
# Traditional Pivot Points
# Assembled by BenTen at UseThinkScript.com
# Based on the formula from https://www.tradingview.com/support/solutions/43000521824-pivot-points-standard/
# Sleepyz - Modifications to show bubbles with label and/or price level
input showonlyLastPeriod = yes;
input show_bubble = yes;
input show_price = yes;
input aggregationPeriod = AggregationPeriod.DAY;
def dayCount = CompoundValue(1, if GetYYYYMMDD() != GetYYYYMMDD()[1] then dayCount[1] + 1 else dayCount[1], 0);
def thisDay = (HighestAll(dayCount) - dayCount) ;
def HIGHprev = high(period = aggregationPeriod)[1];
def LOWprev = low(period = aggregationPeriod)[1];
def CLOSEprev = close(period = aggregationPeriod)[1];
plot PP = if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1])
then double.nan
else (HIGHprev + LOWprev + CLOSEprev) / 3;
plot R1 = PP * 2 - LOWprev;
plot S1 = PP * 2 - HIGHprev;
plot R2 = PP + (HIGHprev - LOWprev);
plot S2 = PP - (HIGHprev - LOWprev);
plot R3 = PP * 2 + (HIGHprev - 2 * LOWprev);
plot S3 = PP * 2 - (2 * HIGHprev - LOWprev);
PP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
AddChartBubble( show_bubble and
if showonlyLastPeriod
then thisDay[1] == 1 and thisDay == 0
else R3 != R3[1],
R3,
"R3: "+if !show_price then ""
else AsText(Round(R3 / TickSize(), 0) * TickSize()), Color.green);
AddChartBubble( show_bubble and
if showonlyLastPeriod
then thisDay[1] == 1 and thisDay == 0
else R2 != R2[1],
R2,
"R2: "+if !show_price then ""
else AsText(Round(R2 / TickSize(), 0) * TickSize()), Color.yellow);
AddChartBubble( show_bubble and
if showonlyLastPeriod
then thisDay[1] == 1 and thisDay == 0
else R1 != R1[1],
R1,
"R1: "+if !show_price then ""
else AsText(Round(R1 / TickSize(), 0) * TickSize()), Color.red);
AddChartBubble( show_bubble and
if showonlyLastPeriod
then thisDay[1] == 1 and thisDay == 0
else PP != PP[1],
PP,
"PP: "+if !show_price then ""
else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);
AddChartBubble( show_bubble and
if showonlyLastPeriod
then thisDay[1] == 1 and thisDay == 0
else S3 != S3[1],
S3,
"S3: "+if !show_price then ""
else AsText(Round(S3 / TickSize(), 0) * TickSize()), Color.gray, no);
AddChartBubble( show_bubble and
if showonlyLastPeriod
then thisDay[1] == 1 and thisDay == 0
else S2 != S2[1],
S2,
"S2: "+if !show_price then ""
else AsText(Round(S2 / TickSize(), 0) * TickSize()), Color.dark_orange, no);
AddChartBubble( show_bubble and
if showonlyLastPeriod
then thisDay[1] == 1 and thisDay == 0
else S1 != S1[1],
S1,
"S1: "+if !show_price then ""
else AsText(Round(S1 / TickSize(), 0) * TickSize()), Color.white, NO);
#
# TD Ameritrade IP Company, Inc. (c) 2011-2021
#
# Source code isn't available.
input showOnlyToday = No;
input timeFrame = {default "DAY", "WEEK", "MONTH"};
plot R3 = Double.NaN;
plot R2 = Double.NaN;
plot R1 = Double.NaN;
plot PP = Double.NaN;
plot S1 = Double.NaN;
plot S2 = Double.NaN;
plot S3 = Double.NaN;
How would you make the pivot lines skinnier?
This seems to work by referencing the pivot point as pivotpoints().pp@BenTen I am using standard pivot point study that comes with TOS. Is it possible to enable an alert whenever price crosses the pivot level up or down?
#
# TD Ameritrade IP Company, Inc. (c) 2011-2021
#
# Source code isn't available.
input showOnlyToday = No;
input timeFrame = {default "DAY", "WEEK", "MONTH"};
plot R3 = Double.NaN;
plot R2 = Double.NaN;
plot R1 = Double.NaN;
plot PP = Double.NaN;
plot S1 = Double.NaN;
plot S2 = Double.NaN;
plot S3 = Double.NaN;
alert(close crosses pivotpoints().pp, "PP cross", alert.bar, sound.ding);
Thank You @SleepyZThis seems to work by referencing the pivot point as pivotpoints().pp
Code:# # TD Ameritrade IP Company, Inc. (c) 2011-2021 # # Source code isn't available. input showOnlyToday = No; input timeFrame = {default "DAY", "WEEK", "MONTH"}; plot R3 = Double.NaN; plot R2 = Double.NaN; plot R1 = Double.NaN; plot PP = Double.NaN; plot S1 = Double.NaN; plot S2 = Double.NaN; plot S3 = Double.NaN; alert(close crosses pivotpoints().pp, "PP cross", alert.bar, sound.ding);
Here is the PivotPoints code that will plot the TOS PivotPoints as well as the alert.Thank You @SleepyZ
#
# TD Ameritrade IP Company, Inc. (c) 2011-2021
#
# Source code isn't available.
input showOnlyToday = No;
input timeFrame = {default "DAY", "WEEK", "MONTH"};
plot R3 = pivotpoints().r3;
plot R2 = pivotpoints().r2;
plot R1 = pivotpoints().r1;
plot PP = pivotpoints().pp;
plot S1 = pivotpoints().s1;
plot S2 = pivotpoints().s2;
plot S3 = pivotpoints().s3;
alert(close crosses pp, "PP cross", alert.bar, sound.ding);
r3.setdefaultColor(color.red);
r2.setdefaultColor(color.red);
r1.setdefaultColor(color.red);
pp.setdefaultColor(color.magenta);
s1.setdefaultColor(color.green);
s2.setdefaultColor(color.green);
s3.setdefaultColor(color.green);
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
A | Scan for Person Pivot levels | Playground | 3 | |
A | Fibonacci Pivot Zones? | Indicators | 1 | |
K | Modified a script to get Floor Trader Pivot Points but did something wrong | Questions | 2 | |
A | Daily camarilla pivot points with pre and post market data | Indicators | 2 | |
M | How to extend some pivot lines to the right | Questions | 1 |