How to plot Vertical lines at specific times selected in different colors

Mcanabal

Member
Plus
How to plot vertical lines at specific times selected in different colors 2 or more in one indicator
 
Last edited:
Any help here??????this is the script that I use must!!!!, any help could be very appreciated!!!!

See if this helps.

The prior code was using double.positive_infinity and double.negative_infinity to draw the vertical lines from the top of the chart to the bottom of the chart. That does not work as coded now.

To fix that, the following code uses high+1000 and low-1000 to draw the lines as shown below

Screenshot 2024-07-09 123818.jpg
Code:
input time1 = 1000;
input time2 = 1100;

def c = close;
def o = open;

def x1w = SecondsFromTime(time1) == 0 and c;
def h1w = if x1w == 1 then high + 1000 else Double.NaN;
def l1w = if x1w == 1 then low - 1000 else Double.NaN;
AddChart(h1w, l1w, 0, 0, ChartType.BAR, Color.WHITE);
def x1 = SecondsFromTime(time1) == 0 and c[-1];
def h1g = if c > o and x1 then high + 1000 else Double.NaN;
def l1g = if c > o and x1 then low - 0000 else Double.NaN;
AddChart(h1g, l1g, 0, 0, ChartType.CANDLE, Color.GREEN);
def h1r = if c < o and x1 then high + 1000 else Double.NaN;
def l1r = if c < o and x1 then low - 1000 else Double.NaN;
AddChart(h1r, l1r, 0, 0, ChartType.CANDLE, Color.RED);

def x2w = SecondsFromTime(time2) == 0 and c;
def h2w = if x2w then high + 1000 else Double.NaN;
def l2w = if x2w then low - 1000 else Double.NaN;
AddChart(h2w, l2w, 0, 0, ChartType.CANDLE, Color.WHITE);
def x2 = SecondsFromTime(time2) == 0 and c[-1];
def h2g = if c > o and  x2 then high + 1000 else Double.NaN;
def l2g = if c > o and  x2 then low - 1000 else Double.NaN;
AddChart(h2g, l2g, 0, 0, ChartType.CANDLE, Color.GREEN);
def h2r = if c < o and  x2 then high + 1000 else Double.NaN;
def l2r = if c < o and  x2 then low - 1000 else Double.NaN;
AddChart(h2r, l2r, 0, 0, ChartType.CANDLE, Color.RED);

#
 
See if this helps.

The prior code was using double.positive_infinity and double.negative_infinity to draw the vertical lines from the top of the chart to the bottom of the chart. That does not work as coded now.

To fix that, the following code uses high+1000 and low-1000 to draw the lines as shown below
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
394 Online
Create Post

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