trouble with plot going across full day

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:

exampl1TOS.png


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:

tosExample2.png

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

View attachment 19853

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...
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:

View attachment 19853

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:

View attachment 19854
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);

See if this works the way you want.

Each of the pre hi/low/close defs are extended by use of 'if isnan(close) then a reference to the def name[1]' These lines will extend thoughout the day as you requested.

The second part will remove the pretime if you select input limit_lines_to_after_pretime = yes;

This is shown in the upper chart in the image below where the lines in the pretime are removed and the final of each line after the pretime is plotted as an extended line.

This input set to no results in the lower chart, also now with extended lines.

Screenshot 2023-10-17 172132.png
Code:
input limit_lines_to_after_pretime = yes;
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 isnan(close) then prehi[1]
  else if !pretime[1] and pretime then high
  else if pretime and high > prehi[1] then high
  else prehi[1];

def prelo = if isnan(close) then prelo[1]
  else if !pretime[1] and pretime then low
  else if pretime and low < prelo[1] then low
  else prelo[1];

def preclose = if isnan(close) then preclose[1]
  else 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;
def R6 = (prehi / prelo) * preclose;
plot R6w = if limit_lines_to_after_pretime and pretime then double.nan else R6;
plot R5w = if limit_lines_to_after_pretime and pretime then double.nan else (preclose + rangew * (1.1) / 2) + 1.168 * ((preclose + rangew * (1.1) / 2) – (preclose + rangew * (1.1) / 4));
plot R4w = if limit_lines_to_after_pretime and pretime then double.nan else preclose + rangew * (1.1) / 2;
plot R3w = if limit_lines_to_after_pretime and pretime then double.nan else preclose + rangew * (1.1) / 4;
plot R2w = if limit_lines_to_after_pretime and pretime then double.nan else  preclose + rangew * (1.1) / 6;
plot R1w = if limit_lines_to_after_pretime and pretime then double.nan else preclose + rangew * (1.1) / 12;
plot S1w = if limit_lines_to_after_pretime and pretime then double.nan else preclose - rangew * (1.1) / 12;
plot S2w = if limit_lines_to_after_pretime and pretime then double.nan else preclose - rangew * (1.1) / 6;
plot S3w = if limit_lines_to_after_pretime and pretime then double.nan else preclose - rangew * (1.1) / 4;
plot S4w = if limit_lines_to_after_pretime and pretime then double.nan else preclose - rangew * (1.1) / 2;
plot S5w = if limit_lines_to_after_pretime and pretime then double.nan else (preclose - rangew * (1.1) / 2) - 1.168 * ((preclose - rangew * (1.1) / 4) - (preclose - rangew * (1.1) / 2));
plot S6w = if limit_lines_to_after_pretime and pretime then double.nan else (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);
 
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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