Hello I have camarilla pivot code. This shows pivot points for all days. How do I turn off previous days pivot lines and only shows for today. I ama not coder and if anyone can help, I appreciate a lot. Thank you.
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2013-2021
#Original by SleepyZ:
https://usethinkscript.com/threads/camarilla-pivot-points-for-thinkorswim.696/post-77438
#R5 & S5 Added by Wiinii
input aggregationPeriod = {default "DAY", "WEEK", "MONTH"};
input length = 25;
input hide_s1_r1 = yes;
input lines = {default dashes, points, triangles, horizontal, squares};
input showbubbles_description = yes;
input showpricebubble = yes;
Assert(length > 0, "'length' should be positive: " + length);
def yyyymmdd = GetYYYYMMDD();
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def period;
switch (aggregationPeriod) {
case DAY:
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
period = Floor(day_number / 7);
case MONTH:
period = Floor(month - First(month));
}
def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % length else count[1], 0);
def start = CompoundValue(1, count < count[1] + period - period[1], yes);
def highValue = if start then Highest(high(period = aggregationPeriod), length)[1] else if highValue[1] != 0 then highValue[1] else Double.NaN;
def lowValue = if start then Lowest(low(period = aggregationPeriod), length)[1] else if lowValue[1] != 0 then lowValue[1] else Double.NaN;
def closeValue = if start then close(period = aggregationPeriod)[1] else closeValue[1];
def range = highValue - lowValue;
plot R6 = (highValue / lowValue) * closeValue;
plot R4 = closeValue + range * (1.1) / 2;
plot R3 = closeValue + range * (1.1) / 4;
plot R5 = r4 + 1.168 * (R4 – R3);
plot R2 = closeValue + range * (1.1) / 6;
plot R1 = closeValue + range * (1.1) / 12;
plot S1 = closeValue - range * (1.1) / 12;
plot S2 = closeValue - range * (1.1) / 6;
plot S3 = closeValue - range * (1.1) / 4;
plot S4 = closeValue - range * (1.1) / 2;
plot S5 = S4-1.168 * (s3 - s4);
plot S6 = (closeValue - (R6 - closeValue));
R1.SetHiding(hide_s1_r1);
S1.SetHiding(hide_s1_r1);
R6.SetDefaultColor(GetColor(6));
R5.SetDefaultColor(GetColor(6));
R4.SetDefaultColor(GetColor(6));
R3.SetDefaultColor(GetColor(6));
R2.SetDefaultColor(GetColor(6));
R1.SetDefaultColor(GetColor(6));
S1.SetDefaultColor(GetColor(5));
S2.SetDefaultColor(GetColor(5));
S3.SetDefaultColor(GetColor(5));
S4.SetDefaultColor(GetColor(5));
S5.SetDefaultColor(GetColor(5));
S6.SetDefaultColor(GetColor(5));
def paintingStrategy = if lines == lines.points then PaintingStrategy.POINTS else if lines == lines.triangles then PaintingStrategy.TRIANGLES else if lines == lines.dashes then PaintingStrategy.DASHES else if lines == lines.horizontal then PaintingStrategy.HORIZONTAL else PaintingStrategy.SQUARES;
R6.SetPaintingStrategy(paintingStrategy);
R5.SetPaintingStrategy(paintingStrategy);
R4.SetPaintingStrategy(paintingStrategy);
R3.SetPaintingStrategy(paintingStrategy);
R2.SetPaintingStrategy(paintingStrategy);
R1.SetPaintingStrategy(paintingStrategy);
S1.SetPaintingStrategy(paintingStrategy);
S2.SetPaintingStrategy(paintingStrategy);
S3.SetPaintingStrategy(paintingStrategy);
S4.SetPaintingStrategy(paintingStrategy);
S5.SetPaintingStrategy(paintingStrategy);
S6.SetPaintingStrategy(paintingStrategy);
#Bubbles to describe Pivot Levels
input bubblemover = 8;
def n = bubblemover;
def n1 = n + 1;
def StartPlot = if showbubbles_description == yes then (IsNaN(close[n]) and !IsNaN(close[n1])) else Double.NaN;
AddChartBubble(StartPlot, R6[n1], "R6 " + (if showpricebubble then AsText(R6[n1]) else ""), Color.GREEN, if close[n1] > R6[n1] then no else yes);
AddChartBubble(StartPlot, R5[n1], "R5 " + (if showpricebubble then AsText(R5[n1]) else ""), Color.GREEN, if close[n1] > R5[n1] then no else yes);
AddChartBubble(StartPlot, R4[n1], "R4 " + (if showpricebubble then AsText(R4[n1]) else ""), Color.GREEN, if close[n1] > R4[n1] then no else yes);
AddChartBubble(StartPlot, R3[n1], "R3 " + (if showpricebubble then AsText(R3[n1]) else ""), Color.GREEN, if close[n1] > R3[n1] then no else yes);
AddChartBubble(StartPlot, R2[n1], "R2 " + (if showpricebubble then AsText(R2[n1]) else ""), Color.GREEN, if close[n1] > R2[n1] then no else yes);
AddChartBubble(StartPlot and hide_s1_r1 == no, R1[n1], "R1 " + (if showpricebubble then AsText(R1[n1]) else ""), Color.GREEN, if close[n1] > R1[n1] then no else yes);
AddChartBubble(StartPlot, S6[n1], "S6 " + (if showpricebubble then AsText(S6[n1]) else ""), Color.RED, if close[n1] > S6[n1] then no else yes);
AddChartBubble(StartPlot, S5[n1], "S5 " + (if showpricebubble then AsText(S5[n1]) else ""), Color.RED, if close[n1] > S5[n1] then no else yes);
AddChartBubble(StartPlot, S4[n1], "S4 " + (if showpricebubble then AsText(S4[n1]) else ""), Color.RED, if close[n1] > S4[n1] then no else yes);
AddChartBubble(StartPlot, S3[n1], "S3 " + (if showpricebubble then AsText(S3[n1]) else ""), Color.RED, if close[n1] > S3[n1] then no else yes);
AddChartBubble(StartPlot, S2[n1], "S2 " + (if showpricebubble then AsText(S2[n1]) else ""), Color.RED, if close[n1] > S2[n1] then no else yes);
AddChartBubble(StartPlot and hide_s1_r1 == no, S1[n1], "S1 " + (if showpricebubble then AsText(S1[n1]) else ""), Color.RED, if close[n1] > S1[n1] then no else yes);
R1.HideBubble();
R2.HideBubble();
R3.HideBubble();
R4.HideBubble();
R5.HideBubble();
R6.HideBubble();
S1.HideBubble();
S2.HideBubble();
S3.HideBubble();
S4.HideBubble();
S5.HideBubble();
S6.HideBubble();