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!
 
@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.
But isn't the pivot point indicator basic as far as its how it is calculated?

The calculation for the pivot point is: pivot point = (High+Low+close)/3

at the very least I would expect these indicators to have their pivot points line up the same considering they use the same formula for the pivot point
 
@gabrobro
But isn't the pivot point indicator basic as far as its how it is calculated?
The calculation for the pivot point is: pivot point = (High+Low+close)/3

Oh my no! ToS has a several Pivot Point Studies which don't plot anything alike.
Screenshot (12).png

And there are dozens of threads of custom pivot point Indicators on this forum all different and within THOSE threads, you will find a huge number of flavors based on those threads.

Here is one that is coded to your basic idea:
https://usethinkscript.com/threads/...ts-indicator-for-thinkorswim.4860/#post-44895 but again, it does not match up w/ the ToS indicator which would say theirs has additional calculations.

The most popular pivot point indicator on the uTS forum with over 187,000 views: https://usethinkscript.com/threads/...ort-resistance-indicator-for-thinkorswim.158/
It compounds the values of H / L / C.
 
Last edited:
Hey @SleepyZ
Can you also modify the code for Pivot Points to painting strategy , show bubbles and within the bubbles whether to show the price like you did for the other Pivot? I tried modiying the code as per your logic, but it didnt return anything.


#
# 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;
Try this link that I did recently https://usethinkscript.com/threads/...nts-indicator-for-thinkorswim.4860/post-77472
 
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

Hi @SleepyZ , I tried your code but oddly the values are still far away from the "Pivot Points Standard AUTO" on TradingView. In Auto mode, it will show Monthly pivot on Daily chart. Any idea how I can make it exactly the same please?

Is it also possible to make the lines shorter so it only extends to past 5 days? Thank you. 🙏🏼


qoW6Woc.png


ZEXqHgA.png
 
Last edited by a moderator:
I've made changes to the to match how it works in trading view. For standard pivot points. I should automatically adjust as well now
https://www.tradingview.com/support/solutions/43000521824-pivot-points-standard/

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
# Updated: Osama Mansour
# Trading View Formula Update


input showonlyLastPeriod = yes;
input show_bubble        = yes;
input show_price         = yes;


def aggregationPeriod = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.DAY
                        else if GetAggregationPeriod() >= AggregationPeriod.FIFTEEN_MIN and GetAggregationPeriod() < AggregationPeriod.DAY  then AggregationPeriod.WEEK
                        else if GetAggregationPeriod() == AggregationPeriod.DAY then AggregationPeriod.MONTH
                        else if GetAggregationPeriod() == AggregationPeriod.WEEK and GetAggregationPeriod() == AggregationPeriod.MONTH then AggregationPeriod.YEAR
                        else AggregationPeriod.MONTH;




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);
plot R4 = PP * 3 + (HIGHprev - 3 * LOWprev);
plot S4 = PP * 3 - (3 * HIGHprev - LOWprev);
plot R5 = PP * 4 + (HIGHprev - 4 * LOWprev);
plot S5 = PP * 4 - (4 * 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);
R4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

AddChartBubble( show_bubble and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else R5 != R5[1],
                R5,
                "R5: " + if !show_price then ""
                       else AsText(Round(R5 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble( show_bubble and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else R4 != R4[1],
                R4,
                "R4: " + if !show_price then ""
                       else AsText(Round(R4 / TickSize(), 0) * TickSize()), Color.GREEN);

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 S5 != S5[1],
                S5,
                "S4: " + if !show_price then ""
                       else AsText(Round(S5 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubble and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else S4 != S4[1],
                S4,
                "S4: " + if !show_price then ""
                       else AsText(Round(S4 / TickSize(), 0) * TickSize()), Color.GRAY, no);

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);
 
I've made changes to the to match how it works in trading view. For standard pivot points. I should automatically adjust as well now
https://www.tradingview.com/support/solutions/43000521824-pivot-points-standard/

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
# Updated: Osama Mansour
# Trading View Formula Update


input showonlyLastPeriod = yes;
input show_bubble        = yes;
input show_price         = yes;


def aggregationPeriod = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.DAY
                        else if GetAggregationPeriod() >= AggregationPeriod.FIFTEEN_MIN and GetAggregationPeriod() < AggregationPeriod.DAY  then AggregationPeriod.WEEK
                        else if GetAggregationPeriod() == AggregationPeriod.DAY then AggregationPeriod.MONTH
                        else if GetAggregationPeriod() == AggregationPeriod.WEEK and GetAggregationPeriod() == AggregationPeriod.MONTH then AggregationPeriod.YEAR
                        else AggregationPeriod.MONTH;




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);
plot R4 = PP * 3 + (HIGHprev - 3 * LOWprev);
plot S4 = PP * 3 - (3 * HIGHprev - LOWprev);
plot R5 = PP * 4 + (HIGHprev - 4 * LOWprev);
plot S5 = PP * 4 - (4 * 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);
R4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

AddChartBubble( show_bubble and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else R5 != R5[1],
                R5,
                "R5: " + if !show_price then ""
                       else AsText(Round(R5 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble( show_bubble and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else R4 != R4[1],
                R4,
                "R4: " + if !show_price then ""
                       else AsText(Round(R4 / TickSize(), 0) * TickSize()), Color.GREEN);

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 S5 != S5[1],
                S5,
                "S4: " + if !show_price then ""
                       else AsText(Round(S5 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubble and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else S4 != S4[1],
                S4,
                "S4: " + if !show_price then ""
                       else AsText(Round(S4 / TickSize(), 0) * TickSize()), Color.GRAY, no);

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);
Nice one!
Is het possible to change the script a little bit so you can choose the timeframe for the pivot point in the input field like: day, week, month quarter?
That would be very helpfull!! than you can add this script 4 times and you have al the pivot points. Many 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
Hello, Thanks for putting together this code. when s3 and r3 is set to no, r3/s3 price bubble continued to show.
 
Hello, Thanks for putting together this code. when s3 and r3 is set to no, r3/s3 price bubble continued to show.

I did not have a yes/no input to show the R3/S3 levels in the original code. Unchecking the plot in the input of those levels did not affect the display of the bubbles for these.

Included in the code below is now an input to display (yes/no) those levels and bubbles. Selecting 'no' will hide the display of those level's lines and bubbles. Similar modifications can be made for other levels.

Also, for clarity, the inputs for show_bubble and show_price were renamed and modified in the code below to clarify that these apply to all bubbles.

In the image, the input is set to 'no' for displaying the R3_S3 levels.
Capture.jpg
Ruby:
# 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_bubbles       = yes;#Hint show_bubbles: turns all bubbles on or off     
input show_bubble_price  = yes;#Hint show_bubble_price: displays price in bubble
input show_level_R3_S3   = yes;#Hint show_level_R3_S3: controls display of level line and bubble

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 = if !show_level_R3_S3 then double.nan else PP * 2 + (HIGHprev - 2 * LOWprev);
plot S3 = if !show_level_R3_S3 then double.nan else 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_bubbles and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else R3 != R3[1],
                R3,
                "R3: " + if !show_bubble_price then ""
                       else AsText(Round(R3 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble( show_bubbles and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else R2 != R2[1],
                R2,
                "R2: " + if !show_bubble_price then ""
                       else AsText(Round(R2 / TickSize(), 0) * TickSize()), Color.YELLOW);

AddChartBubble( show_bubbles and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else R1 != R1[1],
                R1,
                "R1: " + if !show_bubble_price then ""
                       else AsText(Round(R1 / TickSize(), 0) * TickSize()), Color.RED);

AddChartBubble( show_bubbles and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else PP != PP[1],
                PP,
                "PP: " + if !show_bubble_price then ""
                       else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);

AddChartBubble( show_bubbles and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else S3 != S3[1],
                S3,
                "S3: " + if !show_bubble_price then ""
                       else AsText(Round(S3 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubbles and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else S2 != S2[1],
                S2,
                "S2: " + if !show_bubble_price then ""
                       else AsText(Round(S2 / TickSize(), 0) * TickSize()), Color.DARK_ORANGE, no);

AddChartBubble( show_bubbles and
                if showonlyLastPeriod
                then thisDay[1] == 1 and thisDay == 0
                else S1 != S1[1],
                S1,
                "S1: " + if !show_bubble_price then ""
                       else AsText(Round(S1 / TickSize(), 0) * TickSize()), Color.WHITE, no);
 
I did not have a yes/no input to show the R3/S3 levels in the original code. Unchecking the plot in the input of those levels did not affect the display of the bubbles for these.

Included in the code below is now an input to display (yes/no) those levels and bubbles. Selecting 'no' will hide the display of those level's lines and bubbles. Similar modifications can be made for other levels.

Also, for clarity, the inputs for show_bubble and show_price were renamed and modified in the code below to clarify that these apply to all bubbles.

In the image, the input is set to 'no' for displaying the R3_S3 levels.

Hello SleepyZ,
Your indicator works very well, im very new to thinkscript.


I'm trying to change the code to show only 1 (*arg) historical pivot results (e.g. previous month and this month)? and remove the forecasted month, year

Code:
plot PP = if showonlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-2])
          then Double.NaN



and can the code be applied to camarilla pivot as well?

im previously using tradingview, and hope to set the indicators right on top.
 
Last edited:
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
How about Mid points? I've played with the code but I am a novice so no luck so far...
 
Hello SleepyZ,
Your indicator works very well, im very new to thinkscript.


I'm trying to change the code to show only 1 (*arg) historical pivot results (e.g. previous month and this month)? and remove the forecasted month, year

Code:
plot PP = if showonlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-2])
          then Double.NaN



and can the code be applied to camarilla pivot as well?

im previously using tradingview, and hope to set the indicators right on top.

The following mod to the pivot script will allow you to choose how many periods you want to display. It also includes midpivots requested in the next post.

Capture.jpg
Ruby:
# 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
# Updated: Osama Mansour
# Trading View Formula Update

input periods_to_display = 2;
input show_bubble        = yes;
input show_price         = yes;
input show_midpivots     = no;

def aggregationPeriod = if GetAggregationPeriod() < AggregationPeriod.DAY
                        then AggregationPeriod.DAY
                        else if GetAggregationPeriod() >= AggregationPeriod.DAY and
                                GetAggregationPeriod() < AggregationPeriod.WEEK
                        then AggregationPeriod.WEEK
                        else if GetAggregationPeriod() == AggregationPeriod.WEEK
                        then AggregationPeriod.MONTH
                        else AggregationPeriod.YEAR;

def basis             = if GetAggregationPeriod() < AggregationPeriod.DAY
                        then GetYYYYMMDD()
                        else if GetAggregationPeriod() >= AggregationPeriod.DAY and
                                GetAggregationPeriod() < AggregationPeriod.WEEK
                        then GetWeek()
                        else if GetAggregationPeriod() == AggregationPeriod.WEEK
                        then GetMonth()
                        else GetYear();



def dayCount = CompoundValue(1, if !IsNaN(close(period = aggregationPeriod)) and basis != basis[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 thisDay < periods_to_display and !IsNaN(close(period = aggregationPeriod)) then (HIGHprev + LOWprev + CLOSEprev) / 3
          else Double.NaN;
def pp1 = (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);
plot R4 = PP * 3 + (HIGHprev - 3 * LOWprev);
plot S4 = PP * 3 - (3 * HIGHprev - LOWprev);
plot R5 = PP * 4 + (HIGHprev - 4 * LOWprev);
plot S5 = PP * 4 - (4 * HIGHprev - LOWprev);

#Mid Pivots
plot mr1 = if !show_midpivots then double.nan else (PP + R1) / 2;
plot mr2 = if !show_midpivots then double.nan else (R1 + R2) / 2;
plot mr3 = if !show_midpivots then double.nan else (R2 + R3) / 2;
plot mr4 = if !show_midpivots then double.nan else (R3 + R4) / 2;
plot mr5 = if !show_midpivots then double.nan else (R4 + R5) / 2;

plot ms1 = if !show_midpivots then double.nan else (PP + S1 ) / 2;
plot ms2 = if !show_midpivots then double.nan else (S1 + S2 ) / 2;
plot ms3 = if !show_midpivots then double.nan else (S2 + S3 ) / 2;
plot ms4 = if !show_midpivots then double.nan else (S3 + S4 ) / 2;
plot ms5 = if !show_midpivots then double.nan else (S4 + S5 ) / 2;

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);
R4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

mr1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

DefineGlobalColor("R", Color.RED);
DefineGlobalColor("S", Color.GREEN);
DefineGlobalColor("Mid", Color.YELLOW);

PP.SetDefaultColor(Color.CYAN);
R1.SetDefaultColor(GlobalColor("R"));
R2.SetDefaultColor(GlobalColor("R"));
R3.SetDefaultColor(GlobalColor("R"));
R4.SetDefaultColor(GlobalColor("R"));
R5.SetDefaultColor(GlobalColor("R"));

S1.SetDefaultColor(GlobalColor("S"));
S2.SetDefaultColor(GlobalColor("S"));
S3.SetDefaultColor(GlobalColor("S"));
S4.SetDefaultColor(GlobalColor("S"));
S5.SetDefaultColor(GlobalColor("S"));

mr1.SetDefaultColor(GlobalColor("mid"));
mr2.SetDefaultColor(GlobalColor("mid"));
mr3.SetDefaultColor(GlobalColor("mid"));
mr4.SetDefaultColor(GlobalColor("mid"));
mr5.SetDefaultColor(GlobalColor("mid"));
ms1.SetDefaultColor(GlobalColor("mid"));
ms2.SetDefaultColor(GlobalColor("mid"));
ms3.SetDefaultColor(GlobalColor("mid"));
ms4.SetDefaultColor(GlobalColor("mid"));
ms5.SetDefaultColor(GlobalColor("mid"));

AddChartBubble(show_bubble and
                pp1 != pp1[1],
                R5,
                "R5: " + if !show_price then ""
                       else AsText(Round(R5 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble(show_bubble and
                pp1 != pp1[1],
                R4,
                "R4: " + if !show_price then ""
                       else AsText(Round(R4 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble( show_bubble and
                pp1 != pp1[1],
                R3,
                "R3: " + if !show_price then ""
                       else AsText(Round(R3 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble( show_bubble and
                pp1 != pp1[1],
                R2,
                "R2: " + if !show_price then ""
                       else AsText(Round(R2 / TickSize(), 0) * TickSize()), Color.YELLOW);

AddChartBubble( show_bubble and
                pp1 != pp1[1],
                R1,
                "R1: " + if !show_price then ""
                       else AsText(Round(R1 / TickSize(), 0) * TickSize()), Color.RED);

AddChartBubble( show_bubble and
                pp1 != pp1[1] ,
                PP,
                "PP: " + if !show_price then ""
                       else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);

AddChartBubble( show_bubble and
                pp1 != pp1[1],
                S5,
                "S5: " + if !show_price then ""
                       else AsText(Round(S5 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubble and
                pp1 != pp1[1],
                S4,
                "S4: " + if !show_price then ""
                       else AsText(Round(S4 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubble and
                pp1 != pp1[1],
                S3,
                "S3: " + if !show_price then ""
                       else AsText(Round(S3 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubble and
                pp1 != pp1[1],
                S2,
                "S2: " + if !show_price then ""
                       else AsText(Round(S2 / TickSize(), 0) * TickSize()), Color.DARK_ORANGE, no);

AddChartBubble( show_bubble and
                pp1 != pp1[1],
                S1,
                "S1: " + if !show_price then ""
                       else AsText(Round(S1 / TickSize(), 0) * TickSize()), Color.WHITE, no);
 
The following mod to the pivot script will allow you to choose how many periods you want to display. It also includes midpivots requested in the next post.
small request, remove price from bubble since price plots on the right AXIS, only show letters,,, if possible to move bubbles using 'shiftbubble' or movebubble,,,,
 
small request, remove price from bubble since price plots on the right AXIS, only show letters,,, if possible to move bubbles using 'shiftbubble' or movebubble,,,,

The above code already had an input option to show price in the bubble. The following has addition of bubblemover.

Ruby:
# 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
# Updated: Osama Mansour
# Trading View Formula Update

input periods_to_display = 2;
input show_bubble        = yes;
input show_price         = yes;
input show_midpivots     = no;

def aggregationPeriod = if GetAggregationPeriod() < AggregationPeriod.DAY
                        then AggregationPeriod.DAY
                        else if GetAggregationPeriod() >= AggregationPeriod.DAY and
                                GetAggregationPeriod() < AggregationPeriod.WEEK
                        then AggregationPeriod.WEEK
                        else if GetAggregationPeriod() == AggregationPeriod.WEEK
                        then AggregationPeriod.MONTH
                        else AggregationPeriod.YEAR;

def basis             = if GetAggregationPeriod() < AggregationPeriod.DAY
                        then GetYYYYMMDD()
                        else if GetAggregationPeriod() >= AggregationPeriod.DAY and
                                GetAggregationPeriod() < AggregationPeriod.WEEK
                        then GetWeek()
                        else if GetAggregationPeriod() == AggregationPeriod.WEEK
                        then GetMonth()
                        else GetYear();



def dayCount = CompoundValue(1, if !IsNaN(close(period = aggregationPeriod)) and basis != basis[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 thisDay < periods_to_display and !IsNaN(close(period = aggregationPeriod)) then (HIGHprev + LOWprev + CLOSEprev) / 3
          else Double.NaN;
def pp1 = (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);
plot R4 = PP * 3 + (HIGHprev - 3 * LOWprev);
plot S4 = PP * 3 - (3 * HIGHprev - LOWprev);
plot R5 = PP * 4 + (HIGHprev - 4 * LOWprev);
plot S5 = PP * 4 - (4 * HIGHprev - LOWprev);

#Mid Pivots
plot mr1 = if !show_midpivots then double.nan else (PP + R1) / 2;
plot mr2 = if !show_midpivots then double.nan else (R1 + R2) / 2;
plot mr3 = if !show_midpivots then double.nan else (R2 + R3) / 2;
plot mr4 = if !show_midpivots then double.nan else (R3 + R4) / 2;
plot mr5 = if !show_midpivots then double.nan else (R4 + R5) / 2;

plot ms1 = if !show_midpivots then double.nan else (PP + S1 ) / 2;
plot ms2 = if !show_midpivots then double.nan else (S1 + S2 ) / 2;
plot ms3 = if !show_midpivots then double.nan else (S2 + S3 ) / 2;
plot ms4 = if !show_midpivots then double.nan else (S3 + S4 ) / 2;
plot ms5 = if !show_midpivots then double.nan else (S4 + S5 ) / 2;

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);
R4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

mr1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

DefineGlobalColor("R", Color.RED);
DefineGlobalColor("S", Color.GREEN);
DefineGlobalColor("Mid", Color.YELLOW);

PP.SetDefaultColor(Color.CYAN);
R1.SetDefaultColor(GlobalColor("R"));
R2.SetDefaultColor(GlobalColor("R"));
R3.SetDefaultColor(GlobalColor("R"));
R4.SetDefaultColor(GlobalColor("R"));
R5.SetDefaultColor(GlobalColor("R"));

S1.SetDefaultColor(GlobalColor("S"));
S2.SetDefaultColor(GlobalColor("S"));
S3.SetDefaultColor(GlobalColor("S"));
S4.SetDefaultColor(GlobalColor("S"));
S5.SetDefaultColor(GlobalColor("S"));

mr1.SetDefaultColor(GlobalColor("mid"));
mr2.SetDefaultColor(GlobalColor("mid"));
mr3.SetDefaultColor(GlobalColor("mid"));
mr4.SetDefaultColor(GlobalColor("mid"));
mr5.SetDefaultColor(GlobalColor("mid"));
ms1.SetDefaultColor(GlobalColor("mid"));
ms2.SetDefaultColor(GlobalColor("mid"));
ms3.SetDefaultColor(GlobalColor("mid"));
ms4.SetDefaultColor(GlobalColor("mid"));
ms5.SetDefaultColor(GlobalColor("mid"));

input bubblemover = 1;
def b=bubblemover;
def b1=b+1;

AddChartBubble(show_bubble and
                pp1[b] != pp1[b1],
                R5,
                "R5: " + if !show_price then ""
                       else AsText(Round(R5 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble(show_bubble and
                pp1[b] != pp1[b1],
                R4,
                "R4: " + if !show_price then ""
                       else AsText(Round(R4 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble( show_bubble and
                pp1[b] != pp1[b1],
                R3,
                "R3: " + if !show_price then ""
                       else AsText(Round(R3 / TickSize(), 0) * TickSize()), Color.GREEN);

AddChartBubble( show_bubble and
               pp1[b] != pp1[b1],
                R2,
                "R2: " + if !show_price then ""
                       else AsText(Round(R2 / TickSize(), 0) * TickSize()), Color.green);

AddChartBubble( show_bubble and
                pp1[b] != pp1[b1],
                R1,
                "R1: " + if !show_price then ""
                       else AsText(Round(R1 / TickSize(), 0) * TickSize()), Color.green);

AddChartBubble( show_bubble and
                pp1[b] != pp1[b1],
                PP,
                "PP: " + if !show_price then ""
                       else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);

AddChartBubble( show_bubble and
                pp1[b] != pp1[b1],
                S5,
                "S5: " + if !show_price then ""
                       else AsText(Round(S5 / TickSize(), 0) * TickSize()), Color.red, no);

AddChartBubble( show_bubble and
                pp1[b] != pp1[b1],
                S4,
                "S4: " + if !show_price then ""
                       else AsText(Round(S4 / TickSize(), 0) * TickSize()), Color.red, no);

AddChartBubble( show_bubble and
                pp1[b] != pp1[b1],
                S3,
                "S3: " + if !show_price then ""
                       else AsText(Round(S3 / TickSize(), 0) * TickSize()), Color.red, no);

AddChartBubble( show_bubble and
                pp1[b] != pp1[b1],
                S2,
                "S2: " + if !show_price then ""
                       else AsText(Round(S2 / TickSize(), 0) * TickSize()), Color.red, no);

AddChartBubble( show_bubble and
                pp1[b] != pp1[b1],
                S1,
                "S1: " + if !show_price then ""
                       else AsText(Round(S1 / TickSize(), 0) * TickSize()), Color.red, no);
 
if someone is interested, this is the formula of the TOS pivot points work. This script not include extended trading hour, only work like TOS script in futures (allways) and stocks in Regular trading hour

Code:
#By ezeguada. Code cracked from TOS script Pivot Points.

def max = high(period = aggregationperiod.DAY)[1];
def min = low(period = aggregationperiod.DAY)[1];
def spot = close(period = aggregationperiod.DAY)[1];

def poc = (max + min + spot) / 3;
def sup1 = poc - (max - poc);
def sup2 = poc - (max - min);
def res1 = poc + (poc - min);
def res2 = poc + (max - min);

plot l1 = poc;
l1.SetDefaultColor(Color.MAGENTA);
l1.setPaintingStrategy(paintingStrategy.HORIZONTAL);

plot l2 = sup1;
l2.SetDefaultColor(Color.GREEN);
l2.setPaintingStrategy(paintingStrategy.HORIZONTAL);

plot l3 = sup2;
l3.SetDefaultColor(Color.GREEN);
l3.setPaintingStrategy(paintingStrategy.HORIZONTAL);

plot l4 = res1;
l4.SetDefaultColor(Color.RED);
l4.setPaintingStrategy(paintingStrategy.HORIZONTAL);

plot l5 = res2;
l5.SetDefaultColor(Color.RED);
l5.setPaintingStrategy(paintingStrategy.HORIZONTAL);
 
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
My bubble is on the right blocking the most recent candles when I choose the Monthly period. Is there a way to have it shown on the left like yours?
 
My bubble is on the right blocking the most recent candles when I choose the Monthly period. Is there a way to have it shown on the left like yours?

First, try using the input bubblemover in the above code by entering plus/minus numbers to position the bubbles where you would like them. Otherwise, provide the code you are using and a chart image showing the problem you are experiencing.
 
Last edited:
First, try using the input bubblemover in the above code by entering plus/minus numbers to position the bubbles where you would like them. Otherwise, provide the code you are using and a chart image showing the problem you are experiencing.
Sorry, I'm not good with TOS scripts so where do I find the bubblemover?
 

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
367 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