ToS Pivot Points Indicator for ThinkorSwim

Ronin13

Member
Have searched high and low but cannot find anything akin to the standard Traditional Pivot Points indicator for ToS:

Wq1EmI9.png


Anyone have any leads, please help?

Thanks!
 
yes i have @BenTen , ToS does have it as a default indicator. however, it is very crude (see image below) , plus the source code is inaccessible. and yes, i have tried all the indicators there, other 3 are variations of the PP

LASk6Pl.png
 
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);
 
thanks @BenTen , gave this a spin. looks good, only the open and close timeframe does not seem to gel with futures contracts O&C.

and yes - can you please advise the code needed to label the lines S3 through R3 (as suggested by @Bugs_Munny) as well as to change line appearance? (e.g. dotted lines)
 
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 !!!
 
How can I name the text. S1, S2, S3, PP, R1, R2, R3? Thanks !!!

This puts bubbles with pivot names and price levels for each pivot point.
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/
# 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);
Capture.jpg
 
Does anyone know why the above code is "off" from the delivered PivotPoints within TOS? In some cases, they do not line up with any values. I find it strange if they are both using the "traditional" method of calculating the data points. Its all the same math. ??
 
TOS pivot points calculation is proprietary and my understanding slightly different than traditional pivot points. Here is the code:

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;
 
@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?
This 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);
 
This 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);
Thank You @SleepyZ
 
Here is the PivotPoints code that will plot the TOS PivotPoints as well as the alert.
#
# 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);
 
Ben I have been trying to crack this for days, you are truly awesome thank you.
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!]

Also, I will add in my opinion it is more accurate than the one provided by tos.

xxeLWy5.png
 
Last edited:
Hello All,

For some reason my central pivot range seems to be offset. The reason I know this is because The "pivot point" that is populated using the CPR code that @BenTen provided if slightly different from the "pivot point" that Thinkorswim populates for me using their pivot point indicator. Any thoughts on whats wrong and how I can fix this?

Thanks!
 
@gabrobro It is not that they are 'wrong'. It is that they are calculated differently. If you are asking how the ToS PivotPoints is calculated, ToS does not share the code for that particular indicator so we can't know that.

There are dozens of pivot point studies on this forum though. If this one is not fitting your strategy, perhaps plugging and playing some others would help.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
238 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top