# 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);
For anyone wondering what is the best time frame for bentens pivot code, it is the 4 day, it does wonders when working alongside the daily. Also, I recommend the swingarm to go along with it, an exceptional tool that will assist in confirming these pivots. I trade silver and gold and well I think the below picture speaks for itself. A powerful tool in assisting your trading, Good luck!]Ben I have been trying to crack this for days, you are truly awesome thank you.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Pivot Points Standard Pine to ToS | Questions | 1 | ||
A | ToS Pivot Points Indicator for ThinkorSwim | Questions | 10 | |
R | TOS trade journal with RTD function | Questions | 1 | |
K | TOS Entries and Targets | Questions | 1 | |
H | Charting Capital inflow and outflows in TOS | Questions | 3 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.