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!
 

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

Hi everyone, first post here. I found this forum while search for Cam scripts for TOS.
I loaded a script I found on here and am wondering if there is a way to remove the turquoise line on the chart that is following the price in sharp moves. The smoother turquoise line is an EMA. I'd like the ones that moves sharply removed.
Here is the script and a screenshot.

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);
 
@Hardline4 Hi everyone, first post here. I found this forum while search for Cam scripts for TOS.
I loaded a script I found on here and am wondering if there is a way to remove the turquoise line on the chart that is following the price in sharp moves. The smoother turquoise line is an EMA. I'd like the ones that moves sharply removed.
Here is the script and a screenshot.

I did not find the screenshot, but I am assuming that when you copied and pasted the script, you left the following, llikely stiill at the top of your new script. This is a placeholder in all new studies and normally should always be removed.

plot Data = close;
 
@Hardline4 Hi everyone, first post here. I found this forum while search for Cam scripts for TOS.
I loaded a script I found on here and am wondering if there is a way to remove the turquoise line on the chart that is following the price in sharp moves. The smoother turquoise line is an EMA. I'd like the ones that moves sharply removed.
Here is the script and a screenshot.

I did not find the screenshot, but I am assuming that when you copied and pasted the script, you left the following, llikely stiill at the top of your new script. This is a placeholder in all new studies and normally should always be removed.
That did the trick. Thanks!!!

One more question regarding the script. Is there a way to move the bubble showing the level (R1,R2,S1,S2,etc) to the right side. Its so far to the left into the pre market Im unable to see what the level is.
 
That did the trick. Thanks!!!

One more question regarding the script. Is there a way to move the bubble showing the level (R1,R2,S1,S2,etc) to the right side. Its so far to the left into the pre market Im unable to see what the level is.

This has an input showbubbles_right_edge. If you select yes, it will plot the bubbles to the right edge or no leaves them on the left.

Capture.jpg
Ruby:
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);

input showbubbles_rightedge = yes;
AddChartBubble( show_bubble and
if showonlyLastPeriod
then if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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 if showbubbles_rightedge
     then barnumber()==highestall(barnumber())
     else 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);
 
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.
Hi SleepyZ,
Is there anyway possible this can be plotted as ShowOnExpansion in addition to specifying the bubbles as PP1, PP2, PP3 and so on and forth depending the amount of periods needed?
 
Hi SleepyZ,
Is there anyway possible this can be plotted as ShowOnExpansion in addition to specifying the bubbles as PP1, PP2, PP3 and so on and forth depending the amount of periods needed?

This now has an option to showexpansiononly.

If you choose to display the bubbles and
If you choose showonlyLastPeriod == yes or showexpansiononly == yes
then the bubbles will only show on the right edge for the last period
else if you choose showonlyLastPeriod == no and showexpansiononly == no and showbubbles_rightedge == yes
then the bubbles will display on the right edge of each day displayed
else the bubbles will display on the left edge of each day displayed

If bubbles are displayed for each day the the "PP" bubble will display "PP0", "PP1", "PP2", .etc ... for each day showing on your chart.

Ruby:
input showonlyLastPeriod    = yes;
input showexpansiononly     = no;
input show_bubble           = yes;
input show_price            = no;
input showbubbles_rightedge = yes;

def bn = BarNumber();
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
then AggregationPeriod.MONTH
else if GetAggregationPeriod() == AggregationPeriod.MONTH
then AggregationPeriod.YEAR
else if GetAggregationPeriod() == AggregationPeriod.QUARTER
then AggregationPeriod.YEAR
else AggregationPeriod.MONTH;

def dayCount = CompoundValue(1, 
if !IsNaN(close) and
(if GetAggregationPeriod() < AggregationPeriod.FIFTEEN_MIN
then GetYYYYMMDD() != GetYYYYMMDD()[1]
else if GetAggregationPeriod() >= AggregationPeriod.FIFTEEN_MIN and             
        GetAggregationPeriod() < AggregationPeriod.DAY
then GetWeek() != GetWeek()[1]
else if GetAggregationPeriod() == AggregationPeriod.DAY
then GetMonth() != GetMonth()[1]
else if GetAggregationPeriod() == AggregationPeriod.WEEK
then GetMonth() != GetMonth()[1]
else if GetAggregationPeriod() == AggregationPeriod.MONTH
then GetYear() != GetYear()[1]
else if GetAggregationPeriod() == AggregationPeriod.QUARTER
then GetYear() != GetYear()[1]
else GetMonth() != GetMonth()[1]) then dayCount[1] + 1 else dayCount[1], 0);

def thisDay   = (HighestAll(dayCount) - dayCount) + 1 ;
def HIGHprev  = high(period = aggregationPeriod)[1];
def LOWprev   = low(period = aggregationPeriod)[1];
def CLOSEprev = close(period = aggregationPeriod)[1];


def PP_ =
if IsNaN(close)
then PP_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else (HIGHprev + LOWprev + CLOSEprev) / 3
;
plot PP = if showexpansiononly and !IsNaN(close) then Double.NaN else PP_;

def r1_ =
if IsNaN(close)
then r1_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
PP_ * 2 - LOWprev;
plot R1 = if showexpansiononly and !IsNaN(close) then Double.NaN else r1_;

def r2_ =
if IsNaN(close)
then r2_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
PP_ + (HIGHprev - LOWprev);
plot R2 = if showexpansiononly and !IsNaN(close) then Double.NaN else r2_;

def r3_ =
if IsNaN(close)
then r3_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
PP_ * 2 + (HIGHprev - 2 * LOWprev);
plot R3 = if showexpansiononly and !IsNaN(close) then Double.NaN else r3_;

def r4_ =
if IsNaN(close)
then r4_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
 PP_ * 3 + (HIGHprev - 3 * LOWprev);
plot R4 =  if showexpansiononly and !IsNaN(close) then Double.NaN else r4_;

def r5_ =
if IsNaN(close)
then r5_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
PP_ * 4 + (HIGHprev - 4 * LOWprev);
plot R5 = if showexpansiononly and !IsNaN(close) then Double.NaN else r5_;

def s1_ =
if IsNaN(close)
then s1_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ * 2 - HIGHprev;
plot S1 = if showexpansiononly and !IsNaN(close) then Double.NaN else s1_;

def s2_ =
if IsNaN(close)
then s2_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ - (HIGHprev - LOWprev);
plot S2 = if showexpansiononly and !IsNaN(close) then Double.NaN else s2_;

def s3_ =
if IsNaN(close)
then s3_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ * 2 - (2 * HIGHprev - LOWprev);
plot S3 = if showexpansiononly and !IsNaN(close) then Double.NaN else s3_;

def s4_ =
if IsNaN(close)
then s4_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ * 3 - (3 * HIGHprev - LOWprev);
plot S4 = if showexpansiononly and !IsNaN(close) then Double.NaN else s4_;

def s5_ =
if IsNaN(close)
then s5_[1]
else if showexpansiononly and !IsNaN(close) or
showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ * 4 - (4 * HIGHprev - LOWprev);
plot S5 = if showexpansiononly and !IsNaN(close) then Double.NaN else s5_;

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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else PP != PP[1]
,
PP,
"PP" + thisDay + ": " + if !show_price then ""
else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S5 != S5[1]
,
S5,
"S5: " + if !show_price then ""
else AsText(Round(S5 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1]
else S1 != S1[1]
,
S1,
"S1: " + if !show_price then ""
else AsText(Round(S1 / TickSize(), 0) * TickSize()), Color.WHITE, no);
#
 
Last edited:
This now has an option to showexpansiononly.

If you choose to display the bubbles and
If you choose showonlyLastPeriod == yes or showexpansiononly == yes
then the bubbles will only show on the right edge for the last period
else if you choose showonlyLastPeriod == no and showexpansiononly == no and showbubbles_rightedge == yes
then the bubbles will display on the right edge of each day displayed
else the bubbles will display on the left edge of each day displayed

If bubbles are displayed for each day the the "PP" bubble will display "PP0", "PP1", "PP2", .etc ... for each day showing on your chart.
This is very nice...Big thanks.


Why do we ned expansion on to next day...I see lines getting moved dynamically for the next day also....

can we have labels just for the current day on the right without showing the future/nextday lines. Thanks again
 
This is very nice...Big thanks.


Why do we ned expansion on to next day...I see lines getting moved dynamically for the next day also....

can we have labels just for the current day on the right without showing the future/nextday lines. Thanks again

This should do what you want with all of the options on the original, which has now been revised to fix the extra plots.

Screenshot-2022-11-08-171822.png
Ruby:
input showonlyLastPeriod    = yes;
input showexpansiononly     = no;
input show_bubble           = yes;
input show_price            = no;
input showbubbles_rightedge = yes;

def bn = BarNumber();
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
then AggregationPeriod.MONTH
else if GetAggregationPeriod() == AggregationPeriod.MONTH
then AggregationPeriod.YEAR
else if GetAggregationPeriod() == AggregationPeriod.QUARTER
then AggregationPeriod.YEAR
else AggregationPeriod.MONTH;

def dayCount = CompoundValue(1, 
if !IsNaN(close) and
(if GetAggregationPeriod() < AggregationPeriod.FIFTEEN_MIN
then GetYYYYMMDD() != GetYYYYMMDD()[1]
else if GetAggregationPeriod() >= AggregationPeriod.FIFTEEN_MIN and             
        GetAggregationPeriod() < AggregationPeriod.DAY
then GetWeek() != GetWeek()[1]
else if GetAggregationPeriod() == AggregationPeriod.DAY
then GetMonth() != GetMonth()[1]
else if GetAggregationPeriod() == AggregationPeriod.WEEK
then GetMonth() != GetMonth()[1]
else if GetAggregationPeriod() == AggregationPeriod.MONTH
then GetYear() != GetYear()[1]
else if GetAggregationPeriod() == AggregationPeriod.QUARTER
then GetYear() != GetYear()[1]
else GetMonth() != GetMonth()[1]) then dayCount[1] + 1 else dayCount[1], 0);

def thisDay   = (HighestAll(dayCount) - dayCount) + 1 ;
def HIGHprev  = high(period = aggregationPeriod)[1];
def LOWprev   = low(period = aggregationPeriod)[1];
def CLOSEprev = close(period = aggregationPeriod)[1];


def PP_ =
if IsNaN(close)
then PP_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else (HIGHprev + LOWprev + CLOSEprev) / 3
;
plot PP = if showexpansiononly and !IsNaN(close) then Double.NaN else PP_;

def r1_ =
if IsNaN(close)
then r1_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
PP_ * 2 - LOWprev;
plot R1 = if showexpansiononly and !IsNaN(close) then Double.NaN else r1_;

def r2_ =
if IsNaN(close)
then r2_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
PP_ + (HIGHprev - LOWprev);
plot R2 = if showexpansiononly and !IsNaN(close) then Double.NaN else r2_;

def r3_ =
if IsNaN(close)
then r3_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
PP_ * 2 + (HIGHprev - 2 * LOWprev);
plot R3 = if showexpansiononly and !IsNaN(close) then Double.NaN else r3_;

def r4_ =
if IsNaN(close)
then r4_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
 PP_ * 3 + (HIGHprev - 3 * LOWprev);
plot R4 =  if showexpansiononly and !IsNaN(close) then Double.NaN else r4_;

def r5_ =
if IsNaN(close)
then r5_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else
PP_ * 4 + (HIGHprev - 4 * LOWprev);
plot R5 = if showexpansiononly and !IsNaN(close) then Double.NaN else r5_;

def s1_ =
if IsNaN(close)
then s1_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ * 2 - HIGHprev;
plot S1 = if showexpansiononly and !IsNaN(close) then Double.NaN else s1_;

def s2_ =
if IsNaN(close)
then s2_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ - (HIGHprev - LOWprev);
plot S2 = if showexpansiononly and !IsNaN(close) then Double.NaN else s2_;

def s3_ =
if IsNaN(close)
then s3_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ * 2 - (2 * HIGHprev - LOWprev);
plot S3 = if showexpansiononly and !IsNaN(close) then Double.NaN else s3_;

def s4_ =
if IsNaN(close)
then s4_[1]
else if showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ * 3 - (3 * HIGHprev - LOWprev);
plot S4 = if showexpansiononly and !IsNaN(close) then Double.NaN else s4_;

def s5_ =
if IsNaN(close)
then s5_[1]
else if showexpansiononly and !IsNaN(close) or
showonlyLastPeriod and thisDay != 1
then Double.NaN
else PP_ * 4 - (4 * HIGHprev - LOWprev);
plot S5 = if showexpansiononly and !IsNaN(close) then Double.NaN else s5_;

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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else PP != PP[1]
,
PP,
"PP" + thisDay + ": " + if !show_price then ""
else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S5 != S5[1]
,
S5,
"S5: " + if !show_price then ""
else AsText(Round(S5 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1]
else S1 != S1[1]
,
S1,
"S1: " + if !show_price then ""
else AsText(Round(S1 / TickSize(), 0) * TickSize()), Color.WHITE, no);
#
 
Hi @SleepyZ, I would like to ask if it's possible to have a time-aggregated version, being able to choose the time frame in the input; Day, Week, Month, etc. Thank you

Sure, this should allow you to choose the timeframe along with the other options.

Image is a Quarter aggregation on a 4h chart timeframe
Screenshot-2022-11-22-162725.png
Ruby:
input aggregationPeriod    = aggregationPeriod.DAY;

input showonlyLastPeriod    = yes;
input showexpansiononly     = no;
input show_bubble           = yes;
input show_price            = no;
input showbubbles_rightedge = yes;

def bn = BarNumber();

def thisDay   = getday() != getlastday() ;
def HIGHprev  = high(period = aggregationPeriod)[1];
def LOWprev   = low(period = aggregationPeriod)[1];
def CLOSEprev = close(period = aggregationPeriod)[1];


def PP_ =
if IsNaN(close)
then PP_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else (HIGHprev + LOWprev + CLOSEprev) / 3
;
plot PP = if showexpansiononly and !IsNaN(close) then Double.NaN else PP_;

def r1_ =
if IsNaN(close)
then r1_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
PP_ * 2 - LOWprev;
plot R1 = if showexpansiononly and !IsNaN(close) then Double.NaN else r1_;

def r2_ =
if IsNaN(close)
then r2_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
PP_ + (HIGHprev - LOWprev);
plot R2 = if showexpansiononly and !IsNaN(close) then Double.NaN else r2_;

def r3_ =
if IsNaN(close)
then r3_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
PP_ * 2 + (HIGHprev - 2 * LOWprev);
plot R3 = if showexpansiononly and !IsNaN(close) then Double.NaN else r3_;

def r4_ =
if IsNaN(close)
then r4_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
 PP_ * 3 + (HIGHprev - 3 * LOWprev);
plot R4 =  if showexpansiononly and !IsNaN(close) then Double.NaN else r4_;

def r5_ =
if IsNaN(close)
then r5_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
PP_ * 4 + (HIGHprev - 4 * LOWprev);
plot R5 = if showexpansiononly and !IsNaN(close) then Double.NaN else r5_;

def s1_ =
if IsNaN(close)
then s1_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else PP_ * 2 - HIGHprev;
plot S1 = if showexpansiononly and !IsNaN(close) then Double.NaN else s1_;

def s2_ =
if IsNaN(close)
then s2_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else PP_ - (HIGHprev - LOWprev);
plot S2 = if showexpansiononly and !IsNaN(close) then Double.NaN else s2_;

def s3_ =
if IsNaN(close)
then s3_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else PP_ * 2 - (2 * HIGHprev - LOWprev);
plot S3 = if showexpansiononly and !IsNaN(close) then Double.NaN else s3_;

def s4_ =
if IsNaN(close)
then s4_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else PP_ * 3 - (3 * HIGHprev - LOWprev);
plot S4 = if showexpansiononly and !IsNaN(close) then Double.NaN else s4_;

def s5_ =
if IsNaN(close)
then s5_[1]
else if showexpansiononly and !IsNaN(close) or
showonlyLastPeriod and thisDay
then Double.NaN
else PP_ * 4 - (4 * HIGHprev - LOWprev);
plot S5 = if showexpansiononly and !IsNaN(close) then Double.NaN else s5_;

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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else PP != PP[1]
,
PP,
"PP" + thisDay + ": " + if !show_price then ""
else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S5 != S5[1]
,
S5,
"S5: " + if !show_price then ""
else AsText(Round(S5 / TickSize(), 0) * TickSize()), Color.GRAY, no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
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  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1]
else S1 != S1[1]
,
S1,
"S1: " + if !show_price then ""
else AsText(Round(S1 / TickSize(), 0) * TickSize()), Color.WHITE, no);
#
 
Thanks so much!
@SleepyZ, it looks like there was removed the midpivots. Is it possible to bring them back for this time-aggregated version, please?

Sure, I revised it to use the Ben's original code with the updates

Screenshot-2022-11-23-071317.png
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
# Updated by Sleepyz with additional input options

input aggregationPeriod    = aggregationPeriod.DAY;

input showonlyLastPeriod    = yes;
input showexpansiononly     = no;
input show_bubble           = yes;
input show_price            = no;
input showbubbles_rightedge = yes;
input show_midpivots        = yes;

def bn = BarNumber();

def thisDay   = getday() != getlastday() ;
def HIGHprev  = high(period = aggregationPeriod)[1];
def LOWprev   = low(period = aggregationPeriod)[1];
def CLOSEprev = close(period = aggregationPeriod)[1];


def PP_ =
if IsNaN(close)
then PP_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else (HIGHprev + LOWprev + CLOSEprev) / 3
;
plot PP = if showexpansiononly and !IsNaN(close) then Double.NaN else PP_;

def r1_ =
if IsNaN(close)
then r1_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
PP_ * 2 - LOWprev;
plot R1 = if showexpansiononly and !IsNaN(close) then Double.NaN else r1_;

def r2_ =
if IsNaN(close)
then r2_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
PP_ + (HIGHprev - LOWprev);
plot R2 = if showexpansiononly and !IsNaN(close) then Double.NaN else r2_;

def r3_ =
if IsNaN(close)
then r3_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
PP_ * 2 + (HIGHprev - 2 * LOWprev);
plot R3 = if showexpansiononly and !IsNaN(close) then Double.NaN else r3_;

def r4_ =
if IsNaN(close)
then r4_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
 PP_ * 3 + (HIGHprev - 3 * LOWprev);
plot R4 =  if showexpansiononly and !IsNaN(close) then Double.NaN else r4_;

def r5_ =
if IsNaN(close)
then r5_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else
PP_ * 4 + (HIGHprev - 4 * LOWprev);
plot R5 = if showexpansiononly and !IsNaN(close) then Double.NaN else r5_;

def s1_ =
if IsNaN(close)
then s1_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else PP_ * 2 - HIGHprev;
plot S1 = if showexpansiononly and !IsNaN(close) then Double.NaN else s1_;

def s2_ =
if IsNaN(close)
then s2_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else PP_ - (HIGHprev - LOWprev);
plot S2 = if showexpansiononly and !IsNaN(close) then Double.NaN else s2_;

def s3_ =
if IsNaN(close)
then s3_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else PP_ * 2 - (2 * HIGHprev - LOWprev);
plot S3 = if showexpansiononly and !IsNaN(close) then Double.NaN else s3_;

def s4_ =
if IsNaN(close)
then s4_[1]
else if showonlyLastPeriod and thisDay
then Double.NaN
else PP_ * 3 - (3 * HIGHprev - LOWprev);
plot S4 = if showexpansiononly and !IsNaN(close) then Double.NaN else s4_;

def s5_ =
if IsNaN(close)
then s5_[1]
else if showexpansiononly and !IsNaN(close) or
showonlyLastPeriod and thisDay
then Double.NaN
else PP_ * 4 - (4 * HIGHprev - LOWprev);
plot S5 = if showexpansiononly and !IsNaN(close) then Double.NaN else s5_;

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

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);

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"));

PP.hidebubble();
R1.hidebubble();
R2.hidebubble();
R3.hidebubble();
R4.hidebubble();
R5.hidebubble();

S1.hidebubble();
S2.hidebubble();
S3.hidebubble();
S4.hidebubble();
S5.hidebubble();


AddChartBubble(show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R5 != R5[1]
,
R5,
"R5: " + if !show_price then ""
else AsText(Round(R5 / TickSize(), 0) * TickSize()), globalcolor("R"));

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R4 != R4[1]
,
R4,
"R4: " + if !show_price then ""
else AsText(Round(R4 / TickSize(), 0) * TickSize()), globalcolor("R"));

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R3 != R3[1]
,
R3,
"R3: " + if !show_price then ""
else AsText(Round(R3 / TickSize(), 0) * TickSize()), globalcolor("R"));

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R2 != R2[1]
,
R2,
"R2: " + if !show_price then ""
else AsText(Round(R2 / TickSize(), 0) * TickSize()), globalcolor("R"));

AddChartBubble(show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R1 != R1[1]
,
R1,
"R1: " + if !show_price then ""
else AsText(Round(R1 / TickSize(), 0) * TickSize()), globalcolor("R"));

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else PP != PP[1]
,
PP,
"PP" + thisDay + ": " + if !show_price then ""
else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S5 != S5[1]
,
S5,
"S5: " + if !show_price then ""
else AsText(Round(S5 / TickSize(), 0) * TickSize()), globalcolor("S"), no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S4 != S4[1]
,
S4,
"S4: " + if !show_price then ""
else AsText(Round(S4 / TickSize(), 0) * TickSize()), globalcolor("S"), no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S3 != S3[1]
,
S3,
"S3: " + if !show_price then ""
else AsText(Round(S3 / TickSize(), 0) * TickSize()), globalcolor("S"), no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S2 != S2[1]
,
S2,
"S2: " + if !show_price then ""
else AsText(Round(S2 / TickSize(), 0) * TickSize()), globalcolor("S"), no);

AddChartBubble(show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1]
else S1 != S1[1]
,
S1,
"S1: " + if !show_price then ""
else AsText(Round(S1 / TickSize(), 0) * TickSize()), globalcolor("S"), no);
#


#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;

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("Mid", Color.YELLOW);
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"));

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"));

mr1.hidebubble();
mr2.hidebubble();
mr3.hidebubble();
mr4.hidebubble();
mr5.hidebubble();
ms1.hidebubble();
ms2.hidebubble();
ms3.hidebubble();
ms4.hidebubble();
ms5.hidebubble();

AddChartBubble(show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R5 != R5[1]
,
mr5,
"MR5: " + if !show_price then ""
else AsText(Round(mR5 / TickSize(), 0) * TickSize()), globalcolor("Mid"));

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R4 != R4[1]
,
mR4,
"MR4: " + if !show_price then ""
else AsText(Round(mR4 / TickSize(), 0) * TickSize()), globalcolor("Mid"));

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R3 != R3[1]
,
mR3,
"MR3: " + if !show_price then ""
else AsText(Round(mR3 / TickSize(), 0) * TickSize()), globalcolor("Mid"));

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R2 != R2[1]
,
mR2,
"MR2: " + if !show_price then ""
else AsText(Round(mR2 / TickSize(), 0) * TickSize()), globalcolor("Mid"));

AddChartBubble(show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R1 != R1[1]
,
mR1,
"MR1: " + if !show_price then ""
else AsText(Round(mR1 / TickSize(), 0) * TickSize()), globalcolor("Mid"));

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S5 != S5[1]
,
mS5,
"MS5: " + if !show_price then ""
else AsText(Round(mS5 / TickSize(), 0) * TickSize()), globalcolor("Mid"), no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S4 != S4[1]
,
mS4,
"MS4: " + if !show_price then ""
else AsText(Round(mS4 / TickSize(), 0) * TickSize()), globalcolor("Mid"), no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S3 != S3[1]
,
mS3,
"MS3: " + if !show_price then ""
else AsText(Round(mS3 / TickSize(), 0) * TickSize()), globalcolor("Mid"), no);

AddChartBubble( show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S2 != S2[1]
,
mS2,
"MS2: " + if !show_price then ""
else AsText(Round(mS2 / TickSize(), 0) * TickSize()), globalcolor("Mid"), no);

AddChartBubble(show_bubble and
if showonlyLastPeriod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1]
else S1 != S1[1]
,
mS1,
"MS1: " + if !show_price then ""
else AsText(Round(mS1 / TickSize(), 0) * TickSize()), globalcolor("Mid"), no);
#
 
Here is the PivotPoints code that will plot the TOS PivotPoints as well as the alert.

Thank you for sharing this! Two questions:

1. "show only today" doesn't seem to be working; is there by chance a tweak to make that work so it shows only the current day?
2. would it be possible to show the lines in the right expansion area only?

I know it's already kind of a hack since we don't have the source code, I appreciate any insight!
 
Thank you for sharing this! Two questions:

1. "show only today" doesn't seem to be working; is there by chance a tweak to make that work so it shows only the current day?
2. would it be possible to show the lines in the right expansion area only?

I know it's already kind of a hack since we don't have the source code, I appreciate any insight!

Sure, your 2 requests were added along with the other input option enhancements I have provided with other PivotPoint studies.

Screenshot-2022-12-02-061857.png
Ruby:
#TOS_PivotPoints_Enhanced
#
# TD Ameritrade IP Company, Inc. (c) 2011-2021
#
# Source code isn't available.
# Sleepyz added optional inputs

input showOnlyToday         = yes;
input showexpansiononly     = no;
input timeFrame             = {default "DAY", "WEEK", "MONTH"};
input show_bubble           = yes;
input show_price            = no;
input showbubbles_rightedge = yes;
input show_midpivots        = yes;
input usealert  = no;


plot R3 = if showexpansiononly and !IsNaN(close)
          then Double.NaN
          else PivotPoints(showOnlyToday, timeFrame).R3;
plot R2 = if showexpansiononly and !IsNaN(close)
          then Double.NaN
          else PivotPoints(showOnlyToday, timeFrame).R2;
plot R1 = if showexpansiononly and !IsNaN(close)
          then Double.NaN
          else PivotPoints(showOnlyToday, timeFrame).R1;
plot PP = if showexpansiononly and !IsNaN(close)
          then Double.NaN
          else PivotPoints(showOnlyToday, timeFrame).PP;
plot S1 = if showexpansiononly and !IsNaN(close)
          then Double.NaN
          else PivotPoints(showOnlyToday, timeFrame).S1;
plot S2 = if showexpansiononly and !IsNaN(close)
          then Double.NaN
          else PivotPoints(showOnlyToday, timeFrame).S2;
plot S3 = if showexpansiononly and !IsNaN(close)
          then Double.NaN
          else PivotPoints(showOnlyToday, timeFrame).s3;

Alert(usealert and close crosses PP, "PP cross", Alert.BAR, Sound.Ding);

DefineGlobalColor("R", Color.RED);
DefineGlobalColor("S", Color.GREEN);
DefineGlobalColor("Mid", Color.YELLOW);
def bn = BarNumber();
def thisDay   = GetDay() != GetLastDay() ;

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);


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


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

PP.HideBubble();
R1.HideBubble();
R2.HideBubble();
R3.HideBubble();

S1.HideBubble();
S2.HideBubble();
S3.HideBubble();

def showonlylastperiod = showOnlyToday;

AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R3 != R3[1]
,
R3,
"R3: " + if !show_price then ""
else AsText(Round(R3 / TickSize(), 0) * TickSize()), GlobalColor("R"));

AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R2 != R2[1]
,
R2,
"R2: " + if !show_price then ""
else AsText(Round(R2 / TickSize(), 0) * TickSize()), GlobalColor("R"));

AddChartBubble(show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R1 != R1[1]
,
R1,
"R1: " + if !show_price then ""
else AsText(Round(R1 / TickSize(), 0) * TickSize()), GlobalColor("R"));

AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else PP != PP[1]
,
PP,
"PP" + thisDay + ": " + if !show_price then ""
else AsText(Round(PP / TickSize(), 0) * TickSize()), Color.CYAN);

AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S3 != S3[1]
,
S3,
"S3: " + if !show_price then ""
else AsText(Round(S3 / TickSize(), 0) * TickSize()), GlobalColor("S"), no);

AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S2 != S2[1]
,
S2,
"S2: " + if !show_price then ""
else AsText(Round(S2 / TickSize(), 0) * TickSize()), GlobalColor("S"), no);

AddChartBubble(show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1]
else S1 != S1[1]
,
S1,
"S1: " + if !show_price then ""
else AsText(Round(S1 / TickSize(), 0) * TickSize()), GlobalColor("S"), no);
#


#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 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;

mr1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mr3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ms3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

DefineGlobalColor("Mid", Color.YELLOW);
mr1.SetDefaultColor(GlobalColor("mid"));
mr2.SetDefaultColor(GlobalColor("mid"));
mr3.SetDefaultColor(GlobalColor("mid"));
ms1.SetDefaultColor(GlobalColor("mid"));
ms2.SetDefaultColor(GlobalColor("mid"));
ms3.SetDefaultColor(GlobalColor("mid"));

mr1.SetDefaultColor(GlobalColor("mid"));
mr2.SetDefaultColor(GlobalColor("mid"));
mr3.SetDefaultColor(GlobalColor("mid"));
ms1.SetDefaultColor(GlobalColor("mid"));
ms2.SetDefaultColor(GlobalColor("mid"));
ms3.SetDefaultColor(GlobalColor("mid"));

mr1.HideBubble();
mr2.HideBubble();
mr3.HideBubble();
ms1.HideBubble();
ms2.HideBubble();
ms3.HideBubble();


AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R3 != R3[1]
,
mr3,
"MR3: " + if !show_price then ""
else AsText(Round(mr3 / TickSize(), 0) * TickSize()), GlobalColor("Mid"));

AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R2 != R2[1]
,
mr2,
"MR2: " + if !show_price then ""
else AsText(Round(mr2 / TickSize(), 0) * TickSize()), GlobalColor("Mid"));

AddChartBubble(show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else R1 != R1[1]
,
mr1,
"MR1: " + if !show_price then ""
else AsText(Round(mr1 / TickSize(), 0) * TickSize()), GlobalColor("Mid"));


AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S3 != S3[1]
,
ms3,
"MS3: " + if !show_price then ""
else AsText(Round(ms3 / TickSize(), 0) * TickSize()), GlobalColor("Mid"), no);

AddChartBubble( show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1] or bn == HighestAll(bn - 1)
else S2 != S2[1]
,
ms2,
"MS2: " + if !show_price then ""
else AsText(Round(ms2 / TickSize(), 0) * TickSize()), GlobalColor("Mid"), no);

AddChartBubble(show_bubble and
if showonlylastperiod  or showexpansiononly
then BarNumber() == HighestAll(BarNumber())
else if showbubbles_rightedge
then thisDay != thisDay[-1]
else S1 != S1[1]
,
ms1,
"MS1: " + if !show_price then ""
else AsText(Round(ms1 / TickSize(), 0) * TickSize()), GlobalColor("Mid"), no);
#
 
Sure, your 2 requests were added along with the other input option enhancements I have provided with other PivotPoint studies.
Hey @SleepyZ, I see that if we select the "Monthly" timeframe in a daily chart, it's not plotting anything; the plots disappear and appear randomly. In the same case, if I am in a 5min chart - for 30 days, there will be no plot. Can you help me? Thanks
 
Hey @SleepyZ, I see that if we select the "Monthly" timeframe in a daily chart, it's not plotting anything; the plots disappear and appear randomly. In the same case, if I am in a 5min chart - for 30 days, there will be no plot. Can you help me? Thanks
It is a limitation of the TOS pivotpoints study that the above enhanced version references. Here is the error message in the upper left corner with both versions that explains it is an issue with the original study. So you will have to reduce the timeframe days to where they will plot without the error message appearing.

TOS PivotPoints study
Screenshot-2022-12-02-163715.png

Enhanced version of TOS PivotPoints study in post #57 above
Screenshot-2022-12-02-164004.png
 
Hi Sleepyz, can you please provide scan for Support/Resistance Zones, codes shown below:

# Support/Resistance Zones around pivot S/R points.
#Added the zones using ATR to the Theotrade Pivots study.
#Additions by Horserider 9/30/2019
input length = 252;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
# User Inputs
input n = 21; #hint n: periods used for pivot calculations.

def Num_Dev_Dn = ATR;

def Num_Dev_up = -ATR;

# Internal Script Reference

script LinePlot {

input BarID = 0;

input Value = 0;

input BarOrigin = 0;

def ThisBar = HighestAll(BarOrigin);

def ValueLine = if BarOrigin == ThisBar

then Value

else Double.NaN;

plot P = if ThisBar - BarID <= BarOrigin

then HighestAll(ValueLine)

else Double.NaN;

}

# Variables

def o = open;

def h = high;

def l = low;

def c = close;

def bar = BarNumber();

def BBar = bar == HighestAll(bar);

# Parent High

def ParentHigh = HighestAll(h);

def ParentHBarOrigin = if h == ParentHigh

then bar

else ParentHBarOrigin[1];

def ParentHBarID = bar - HighestAll(ParentHBarOrigin);

# R1

def hh = fold i = 1 to n + 1

with p = 1

while p

do h > GetValue(h, -i);

def PivotH = if (bar > n and

h == Highest(h, n) and

hh)

then h

else Double.NaN;

def PHValue = if !IsNaN(PivotH)

then PivotH

else PHValue[1];

def PHBarOrigin = if !IsNaN(PivotH)

then bar

else PHBarOrigin[1];

def PHBarID = bar - PHBarOrigin;

# R2

def R2PHValue = if PHBarOrigin != PHBarOrigin[1]

then PHValue[1]

else R2PHValue[1];

def R2PHBarOrigin = if PHBarOrigin != PHBarOrigin[1]

then PHBarOrigin[1]

else R2PHBarOrigin[1];

def R2PHBarID = bar - R2PHBarOrigin;

# R3

def R3PHValue = if R2PHBarOrigin != R2PHBarOrigin[1]

then R2PHValue[1]

else R3PHValue[1];

def R3PHBarOrigin = if R2PHBarOrigin != R2PHBarOrigin[1]

then R2PHBarOrigin[1]

else R3PHBarOrigin[1];

def R3PHBarID = bar - R3PHBarOrigin;

# R4

def R4PHValue = if R3PHBarOrigin != R3PHBarOrigin[1]

then R3PHValue[1]

else R4PHValue[1];

def R4PHBarOrigin = if R3PHBarOrigin != R3PHBarOrigin[1]

then R3PHBarOrigin[1]

else R4PHBarOrigin[1];

def R4PHBarID = bar - R4PHBarOrigin;



# Parent Low

def ParentLow = LowestAll(l);

def ParentLBarOrigin = if l == ParentLow

then bar

else ParentLBarOrigin[1];

def ParentLBarID = bar - HighestAll(ParentLBarOrigin);

# S1

def ll = fold j = 1 to n + 1

with q = 1

while q

do l < GetValue(l, -j);

def PivotL = if (bar > n and

l == Lowest(l, n) and

ll)

then l

else Double.NaN;

def PLValue = if !IsNaN(PivotL)

then PivotL

else PLValue[1];

def PLBarOrigin = if !IsNaN(PivotL)

then bar

else PLBarOrigin[1];

def PLBarID = bar - PLBarOrigin;

# S2

def S2PLValue = if PLBarOrigin != PLBarOrigin[1]

then PLValue[1]

else S2PLValue[1];

def S2PLBarOrigin = if PLBarOrigin != PLBarOrigin[1]

then PLBarOrigin[1]

else S2PLBarOrigin[1];

def S2PLBarID = bar - S2PLBarOrigin;

# S3

def S3PLValue = if S2PLBarOrigin != S2PLBarOrigin[1]

then S2PLValue[1]

else S3PLValue[1];

def S3PLBarOrigin = if S2PLBarOrigin != S2PLBarOrigin[1]

then S2PLBarOrigin[1]

else S3PLBarOrigin[1];

def S3PLBarID = bar - S3PLBarOrigin;

# S4

def S4PLValue = if S3PLBarOrigin != S3PLBarOrigin[1]

then S3PLValue[1]

else S4PLValue[1];

def S4PLBarOrigin = if S3PLBarOrigin != S3PLBarOrigin[1]

then S3PLBarOrigin[1]

else S4PLBarOrigin[1];

def S4PLBarID = bar - S4PLBarOrigin;



# Plots

plot PR1 = LinePlot(BarID = ParentHBarID,

Value = ParentHigh,

BarOrigin = HighestAll(ParentHBarOrigin));

PR1.SetDefaultColor(Color.GREEN);

#addChartBubble(Bar == HighestAll(ParentHBarOrigin), ParentHigh, "High", color.yellow, 1);

plot R1 = LinePlot(BarID = PHBarID,

Value = PHValue,

BarOrigin = PHBarOrigin);

R1.SetDefaultColor(Color.GREEN);

#AddChartBubble(bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.GREEN, 1);



plot LowerBandr1 = R1 + Num_Dev_Dn ;

plot UpperBandr1 = R1 + Num_Dev_up ;

AddCloud(UpperBandr1, R1, Color.GREEN, Color.RED );

AddCloud(LowerBandr1, R1, Color.GREEN, Color.RED );

lowerbandr1.hide();

upperbandr1.hide();





plot R2 = LinePlot(BarID = R2PHBarID,

Value = R2PHValue,

BarOrigin = R2PHBarOrigin);

R2.SetDefaultColor(Color.GREEN);

#AddChartBubble(bar == HighestAll(R2PHBarOrigin), PHValue, "R2", Color.GREEN, 1);



plot LowerBandr2 = R2 + Num_Dev_Dn ;

plot UpperBandr2 = R2 + Num_Dev_up ;

AddCloud(UpperBandr2, R2, Color.GREEN, Color.RED);

AddCloud(LowerBandr2, R2, Color.GREEN, Color.RED);

lowerbandr2.hide();

upperbandr2.hide();



plot R3 = LinePlot(BarID = R3PHBarID,

Value = R3PHValue,

BarOrigin = R3PHBarOrigin);

R3.SetDefaultColor(Color.GREEN);

#AddChartBubble(bar == HighestAll(R3PHBarOrigin), PHValue, "R3", Color.GREEN, 1);



plot LowerBandr3 = R3 + Num_Dev_Dn ;

plot UpperBandr3 = R3 + Num_Dev_up ;

AddCloud(UpperBandr3, R3, Color.LIGHT_GRAY, Color.LIGHT_ORANGE);

AddCloud(LowerBandr3, R3, Color.LIGHT_GRAY, Color.LIGHT_ORANGE);

lowerbandr3.hide();

upperbandr3.hide();



plot R4 = LinePlot(BarID = R4PHBarID,

Value = R4PHValue,

BarOrigin = R4PHBarOrigin);

R4.SetDefaultColor(Color.GREEN);

#AddChartBubble(bar == HighestAll(R4PHBarOrigin), PHValue, "R4", Color.GREEN, 1);



plot LowerBandr4 = R4 + Num_Dev_Dn ;

plot UpperBandr4 = R4 + Num_Dev_up ;

AddCloud(UpperBandr4, R4, Color.LIME, Color.PINK);

AddCloud(LowerBandr4, R4, Color.LIME, Color.PINK);

lowerbandr4.hide();

upperbandr4.hide();





plot PS1 = LinePlot(BarID = ParentLBarID,

Value = ParentLow,

BarOrigin = HighestAll(ParentLBarOrigin));

PS1.SetDefaultColor(Color.RED);

#AddChartBubble(bar == HighestAll(ParentLBarOrigin), ParentLow, "Low", Color.YELLOW, 0);

plot S1 = LinePlot(BarID = PLBarID,

Value = PLValue,

BarOrigin = PLBarOrigin);

S1.SetDefaultColor(Color.RED);

#AddChartBubble(bar == HighestAll(PLBarOrigin), PLValue, "S1", Color.RED, 0);



plot LowerBands1 = S1 + Num_Dev_Dn ;

plot UpperBands1 = S1 + Num_Dev_up ;

AddCloud(UpperBands1, S1, Color.GREEN, Color.RED);

AddCloud(LowerBands1, S1, Color.GREEN, Color.RED);

lowerbands1.hide();

upperbands1.hide();



plot S2 = LinePlot(BarID = S2PLBarID,

Value = S2PLValue,

BarOrigin = S2PLBarOrigin);

S2.SetDefaultColor(Color.RED);

#AddChartBubble(bar == HighestAll(S2PLBarOrigin), PLValue, "S2", Color.RED, 0);



plot LowerBands2 = S2 + Num_Dev_Dn ;

plot UpperBands2 = S2 + Num_Dev_up ;

AddCloud(UpperBands2, S2, Color.GREEN, Color.RED);

AddCloud(LowerBands2, S2, Color.GREEN, Color.RED);

lowerbands2.hide();

upperbands2.hide();



plot S3 = LinePlot(BarID = S3PLBarID,

Value = S3PLValue,

BarOrigin = S3PLBarOrigin);

S3.SetDefaultColor(Color.RED);

#AddChartBubble(bar == HighestAll(S3PLBarOrigin), PLValue, "S3", Color.RED, 0);



plot LowerBands3 = S3 + Num_Dev_Dn ;

plot UpperBands3 = S3 + Num_Dev_up ;

AddCloud(UpperBands3, S3, Color.LIGHT_GRAY, Color.LIGHT_ORANGE);

AddCloud(LowerBands3, S3, Color.LIGHT_GRAY, Color.LIGHT_ORANGE);

lowerbands3.hide();

upperbands3.hide();





plot S4 = LinePlot(BarID = S4PLBarID,

Value = S4PLValue,

BarOrigin = S4PLBarOrigin);

S4.SetDefaultColor(Color.RED);

#AddChartBubble(bar == HighestAll(S4PLBarOrigin), PLValue, "S4", Color.RED, 0);



plot LowerBands4 = S4 + Num_Dev_Dn ;

plot UpperBands4 = S4 + Num_Dev_up ;

AddCloud(UpperBands4, S4, Color.LIME, Color.PINK);

AddCloud(LowerBands4, S4, Color.LIME, Color.PINK);

lowerbands4.hide();

upperbands4.hide();



plot BearScan = if (close crosses below S1) or

(close crosses below S2)

then close

else Double.NaN;

plot BullScan = if (close crosses above R1) or

(close crosses above R2)

then close

else Double.NaN;

# End Code Fractal Array

 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
454 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