Sorry, I'm not good with TOS scripts so where do I find the bubblemover?
plot Data = close;
That did the trick. Thanks!!!@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.
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);
Hi SleepyZ,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?
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); #
This is very nice...Big thanks.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
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); #
Thanks a ton..LIKEDThis should do what you want with all of the options on the original, which has now been revised to fix the extra plots.
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 youThis should do what you want with all of the options on the original, which has now been revised to fix the extra plots.
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
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!Sure, this should allow you to choose the timeframe along with the other options.
Image is a Quarter aggregation on a 4h chart timeframe
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?
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!
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); #
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? ThanksSure, your 2 requests were added along with the other input option enhancements I have provided with other PivotPoint studies.
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.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
Enhanced version of TOS PivotPoints study in post #57 above
#hint: Traditional Pivot Points displays horizontal lines at the pivot point and first three support and resistance areas based on the next higher timeframe (daily pivots are used for intraday timeframes of 30 minutes or more).
# Derived from code by @BenTen
# Ref: https://usethinkscript.com/threads/weekly-and-monthly-pivots-indicator-for-thinkorswim.152/
# Ref: https://usethinkscript.com/threads/tos-pivot-points-indicator-for-thinkorswim.4860/
# Based on formulas from https://www.tradingview.com/support/solutions/43000521824-pivot-points-standard/
input CalcType = {default Fibonacci, Traditional, Classic, Woodie, DM, Camarilla};
input ShowTodayOnly = Yes;
def CurrAggPer = GetAggregationPeriod();
def PPAggPer = if CurrAggPer < AggregationPeriod.THIRTY_MIN then AggregationPeriod.DAY
else if CurrAggPer < AggregationPeriod.WEEK then AggregationPeriod.WEEK
else if CurrAggPer < AggregationPeriod.MONTH then AggregationPeriod.MONTH
else AggregationPeriod.YEAR;
def O = open(period = PPAggPer)[1];
def H = high(period = PPAggPer)[1];
def L = low(period = PPAggPer)[1];
def C = close(period = PPAggPer)[1];
def X = if O == C then H + L + 2 * C
else if C > O then 2 * H + L + C
else 2 * L + H + C;
plot R5;
plot R4;
plot R3;
plot R2;
plot R1;
plot PP;
plot S1;
plot S2;
plot S3;
plot S4;
plot S5;
if (ShowTodayOnly and !IsNaN(close(period = PPAggPer)[-1]) or IsNaN(close))
then {
R1 = Double.NaN;
R2 = Double.NaN;
R3 = Double.NaN;
R4 = Double.NaN;
R5 = Double.NaN;
PP = Double.NaN;
S1 = Double.NaN;
S2 = Double.NaN;
S3 = Double.NaN;
S4 = Double.NaN;
S5 = Double.NaN;
}
else {
switch (CalcType) {
case Fibonacci:
PP = (H + L + C) / 3;
R1 = PP + 0.382 * (H - L);
R2 = PP + 0.618 * (H - L);
R3 = PP + H - L;
R4 = PP + 1.618 * (H - L);
R5 = PP + 2.618 * (H - L);
S1 = PP - 0.382 * (H - L);
S2 = PP - 0.618 * (H - L);
S3 = PP - H + L;
S4 = PP - 1.618 * (H - L);
S5 = PP - 2.618 * (H - L);
case Traditional:
PP = (H + L + C) / 3;
R1 = (2 * PP) - L;
R2 = PP + H - L;
R3 = (2 * PP) + H - (2 * L);
R4 = (3 * PP) + H - (3 * L);
R5 = (4 * PP) + H - (4 * L);
S1 = (2 * PP) - H;
S2 = PP - H + L;
S3 = (2 * PP) - (2 * H) + L;
S4 = (3 * PP) - (3 * H) + L;
S5 = (4 * PP) - (4 * H) + L;
case Classic:
PP = (H + L + C) / 3;
R1 = 2 * PP - L;
R2 = PP + H - L;
R3 = PP + 2 * (H - L);
R4 = PP + 3 * (H - L);
R5 = PP + 4 * (H - L);
S1 = 2 * PP - H;
S2 = PP - H + L;
S3 = PP - 2 * (H - L);
S4 = PP - 3 * (H - L);
S5 = PP - 4 * (H - L);
case Woodie:
PP = (H + L + 2 * open) / 4;
R1 = 2 * PP - L;
R2 = PP + H - L;
R3 = H + 2 * (PP - L);
R4 = R3 + H - L;
R5 = Double.NaN;
S1 = 2 * PP - H;
S2 = PP - H + L;
S3 = L - 2 * (H - PP);
S4 = S3 - H + L;
S5 = Double.NaN;
case DM:
PP = X / 4;
R1 = X / 2 - L;
R2 = Double.NaN;
R3 = Double.NaN;
R4 = Double.NaN;
R5 = Double.NaN;
S1 = X / 2 - H;
S2 = Double.NaN;
S3 = Double.NaN;
S4 = Double.NaN;
S5 = Double.NaN;
case Camarilla:
PP = (H + L + C) / 3;
R1 = C + 1.1 * (H - L) / 12;
R2 = C + 1.1 * (H - L) / 6;
R3 = C + 1.1 * (H - L) / 4;
R4 = C + 1.1 * (H - L) / 2;
R5 = (H / L) * C;
S1 = C - 1.1 * (H - L) / 12;
S2 = C - 1.1 * (H - L) / 6;
S3 = C - 1.1 * (H - L) / 4;
S4 = C - 1.1 * (H - L) / 2;
S5 = C - (R5 - C);
}
}
PP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
# end
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
A | ToS Pivot Points Indicator for ThinkorSwim | Questions | 10 | |
L | Add Custom Sound to a script for TOS | Questions | 3 | |
T | Open Interest & Gamma Levels Charting on TOS Charts | Questions | 0 | |
F | Why Keltners in Stockcharts so different from ToS's? | Questions | 2 | |
S | Data Scraping on TOS | Questions | 3 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.