Problem with AddVerticalLine

Whistlerr

New member
VIP
Can someone tell me if this is valid or what's missing or wrong that's preventing the code below from posting verticle lines... it passed muster in the editor, but nothing posts.

declare upper;
AddVerticalLine(secondstilltime(1800)==0, "Forex open; NZX open", color.green, curve.short_dash);
AddVerticalLine(secondstilltime(2000)==0, "ASX JPX open", color.green, curve.short_dash);
AddVerticalLine(secondstilltime(2100)==0, "SGX open", color.green, curve.short_dash);
 
Code:
# @Whistlerr you are close but the following discussion could move you closer to your goal

declare upper; # 0) plots in bar area. Good habbit to declare for doc purposes, however, It is the default therefore it is superfluous


# 1) Format for AddVertical builtin call is as folow:
# 2) AddVerticalLine ( boolean visible, Any text, CustomColor color, int stroke) ;  
# 3) The thinkscript condition at which the line is to be displayed is termed visible
# 4) You need to supply a condition when met a vertical line to be added to the chart
# 5) If you only supply visible = secondstilltime(1800)==0 then anytime after 1800 there will be a vertical line, however, in order to pinpoint it to an exact spot you need to help the computer and provide both startTime1800 and the end time at which your line needs to be visible


# example NewYork opens
def NYopen0930 = secondsFromTime(0930) > 0 ;
AddVerticalLine(visible = NYopen0930 > 0 && NYopen0930[1] <= 0, text = "NY open", Color =  Color.GRAY, stroke = curve.POINTS ) ;


# required code
# AddVerticalLine(secondstilltime(1800)==0, "Forex open; NZX open", color.green, curve.short_dash);
def StartTime1800 = secondsFromTime(1800) > 0 ;
AddVerticalLine(StartTime1800 > 0 && StartTime1800[1] <= 0, "Forex & NZX open", Color.GREEN, curve.short_dash) ;


#AddVerticalLine(secondstilltime(2000)==0, "ASX JPX open", color.green, curve.short_dash);
def sT2000 = secondsFromTime(2000) > 0 ;
AddVerticalLine(sT2000 > 0 && sT2000[1] <= 0, "ASX JPX open", Color.GREEN, curve.short_dash) ;


#AddVerticalLine(secondstilltime(2100)==0, "SGX open", color.green, curve.short_dash);
def trigger2100 = secondsFromTime(2100) > 0 ;
AddVerticalLine(trigger2100 > 0 && trigger2100[1] <= 0, "SGX open", Color.GREEN, curve.short_dash) ;
 
Code:
# @Whistlerr you are close but the following discussion could move you closer to your goal

declare upper; # 0) plots in bar area. Good habbit to declare for doc purposes, however, It is the default therefore it is superfluous


# 1) Format for AddVertical builtin call is as folow:
# 2) AddVerticalLine ( boolean visible, Any text, CustomColor color, int stroke) ; 
# 3) The thinkscript condition at which the line is to be displayed is termed visible
# 4) You need to supply a condition when met a vertical line to be added to the chart
# 5) If you only supply visible = secondstilltime(1800)==0 then anytime after 1800 there will be a vertical line, however, in order to pinpoint it to an exact spot you need to help the computer and provide both startTime1800 and the end time at which your line needs to be visible


# example NewYork opens
def NYopen0930 = secondsFromTime(0930) > 0 ;
AddVerticalLine(visible = NYopen0930 > 0 && NYopen0930[1] <= 0, text = "NY open", Color =  Color.GRAY, stroke = curve.POINTS ) ;


# required code
# AddVerticalLine(secondstilltime(1800)==0, "Forex open; NZX open", color.green, curve.short_dash);
def StartTime1800 = secondsFromTime(1800) > 0 ;
AddVerticalLine(StartTime1800 > 0 && StartTime1800[1] <= 0, "Forex & NZX open", Color.GREEN, curve.short_dash) ;


#AddVerticalLine(secondstilltime(2000)==0, "ASX JPX open", color.green, curve.short_dash);
def sT2000 = secondsFromTime(2000) > 0 ;
AddVerticalLine(sT2000 > 0 && sT2000[1] <= 0, "ASX JPX open", Color.GREEN, curve.short_dash) ;


#AddVerticalLine(secondstilltime(2100)==0, "SGX open", color.green, curve.short_dash);
def trigger2100 = secondsFromTime(2100) > 0 ;
AddVerticalLine(trigger2100 > 0 && trigger2100[1] <= 0, "SGX open", Color.GREEN, curve.short_dash) ;

i think you mistyped on #5, please edit your post.
if a specific time is specified,
secondstilltime(1800) == 0
then only 1 line could be drawn, IF a bar exists at that time, then it will it be true.
if no bar at that time, then no line.
it won't display lines after that time.
 

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
614 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