andrewescu
New member
Hello everyone I was hoping to get some help with my thinkscript code, I'm trying to plot these camarilla pivot points using pre-market data.
I've got it almost complete but I'm having an issue where today's plot for the pivot points only goes up until the most recent bar of today, instead of plotting the line throughout the entire day Here's what it looks like currently:
I instead what the line to go across the entire day, and I was hoping for some advice on how to achieve this.
I also have another issue with my code I was hoping to get some advice on,
so my code calculates these pivot plot lines based on the pre-market highs and lows but the issue is, everytime in the pre-market when there is a new high or low it will re-draw the plot lines, which makes the plot look a lot more messy, here is a screenshot of it:
Is there a way for me to make it so it only plots one line when the pre-market period is done so that it doesn't keep re-plotting the lines throughout the pre-market?
I've attached my code below, any help or advice would be much appreciated.
I've got it almost complete but I'm having an issue where today's plot for the pivot points only goes up until the most recent bar of today, instead of plotting the line throughout the entire day Here's what it looks like currently:
I instead what the line to go across the entire day, and I was hoping for some advice on how to achieve this.
I also have another issue with my code I was hoping to get some advice on,
so my code calculates these pivot plot lines based on the pre-market highs and lows but the issue is, everytime in the pre-market when there is a new high or low it will re-draw the plot lines, which makes the plot look a lot more messy, here is a screenshot of it:
Is there a way for me to make it so it only plots one line when the pre-market period is done so that it doesn't keep re-plotting the lines throughout the pre-market?
I've attached my code below, any help or advice would be much appreciated.
Code:
input timeframe1 = aggregationPeriod.DAY;
def dayhi = Round(high(period = timeframe1), 2);
def daylo = Round(low(period = timeframe1), 2);
def prevdayhi = dayhi[1];
def prevdaylo = daylo[1];
AddLabel(1, " ", Color.black);
AddLabel(1, "High of Previous Day :" + prevdayhi, Color.GREEN);
AddLabel(1, "Low of Previous Day :" + prevdaylo, Color.PINK);
# bars after close to next day open
input start = 0930;
input end = 1600;
def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0);
def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0);
def pretime = p1 or p2;
def prehi = if !pretime[1] and pretime then high
else if pretime and high > prehi[1] then high
else prehi[1];
def prelo = if !pretime[1] and pretime then low
else if pretime and low < prelo[1] then low
else prelo[1];
def preclose = if !pretime[1] and pretime then close
else if pretime and close < prelo[1] then close
else preclose[1];
AddLabel(1, " ", Color.black);
AddLabel(1, "High of Pre-market :" + prehi, Color.cyan);
AddLabel(1, "Low of Pre-market :" + prelo, Color.yellow);
AddLabel(1, "Close of Pre-market :" + preclose, Color.orange);
AddLabel(1, " ", Color.black);
AddLabel(1, "High of Day :" + dayhi, Color.GREEN);
AddLabel(1, "Low of Day :" + daylo, Color.PINK);
AddLabel(1, " ", Color.black);
def rangew = prehi - prelo;
plot R6w = (prehi / prelo) * preclose;
plot R5w = (preclose + rangew * (1.1) / 2) + 1.168 * ((preclose + rangew * (1.1) / 2) – (preclose + rangew * (1.1) / 4));
plot R4w = preclose + rangew * (1.1) / 2;
plot R3w = preclose + rangew * (1.1) / 4;
plot R2w = preclose + rangew * (1.1) / 6;
plot R1w = preclose + rangew * (1.1) / 12;
plot S1w = preclose - rangew * (1.1) / 12;
plot S2w = preclose - rangew * (1.1) / 6;
plot S3w = preclose - rangew * (1.1) / 4;
plot S4w = preclose - rangew * (1.1) / 2;
plot S5w = (preclose - rangew * (1.1) / 2) - 1.168 * ((preclose - rangew * (1.1) / 4) - (preclose - rangew * (1.1) / 2));
plot S6w = (preclose - (R6w - preclose));
R6w.SetDefaultColor(Color.RED);
R5w.SetDefaultColor(GetColor(7));
R4w.SetDefaultColor(Color.GREEN);
R3w.SetDefaultColor(Color.RED);
R2w.SetDefaultColor(GetColor(7));
R1w.SetDefaultColor(GetColor(7));
S1w.SetDefaultColor(GetColor(7));
S2w.SetDefaultColor(GetColor(7));
S3w.SetDefaultColor(Color.GREEN);
S4w.SetDefaultColor(Color.RED);
S5w.SetDefaultColor(GetColor(7));
S6w.SetDefaultColor(Color.GREEN);
R6w.SetPaintingStrategy(PaintingStrategy.Horizontal);
R5w.SetPaintingStrategy(PaintingStrategy.Horizontal);
R4w.SetPaintingStrategy(PaintingStrategy.Horizontal);
R3w.SetPaintingStrategy(PaintingStrategy.Horizontal);
R2w.SetPaintingStrategy(PaintingStrategy.Horizontal);
R1w.SetPaintingStrategy(PaintingStrategy.Horizontal);
S1w.SetPaintingStrategy(PaintingStrategy.Horizontal);
S2w.SetPaintingStrategy(PaintingStrategy.Horizontal);
S3w.SetPaintingStrategy(PaintingStrategy.Horizontal);
S4w.SetPaintingStrategy(PaintingStrategy.Horizontal);
S5w.SetPaintingStrategy(PaintingStrategy.Horizontal);
S6w.SetPaintingStrategy(PaintingStrategy.Horizontal);