Vertical Lines for Asian, European and US Markets For ThinkOrSwim

Branch

Member
I would like to have a (ThinkScript) vertical line created each day for the Asian, European and US Markets open and close. Does anyone have one available to share?
 
Here's one version that I have - run this on say a 15 minute aggregation. Remember this is an intraday study, so do not load on the daily

Code:
# Global Market Opens and Closes
# Vertical lines mark all open and closes
# Horizontal lines mark US, AUD opens and closes
# ThinkScript Chat Room Group 
# Added Close / Open Lines for US and AUD

declare hide_on_daily;

input Plot_Verticle_Line = yes;
input Show_US = yes;
input Show_London = yes;
input Show_Sydney = yes;
input Show_Asian = yes; #HINT Show_Asian: IMPORTANT, BE SURE to adjust for part of year where USA goes to Daylight Savings but Asia remains on Standard time
input US_Open = 0930;
input US_Close = 1600;
input GBP_Open = 0300;
input GBP_Close = 1130;
input AUD_Open = 1800;
input AUD_Close = 0000;
input JPY_Open = 1900; #HINT JPY_Open: IMPORTANT, BE SURE to adjust for part of year where USA goes to Daylight Savings but Asia remains on Standard time
input JPY_Close = 0100; #HINT JPT_Close: IMPORTANT, BE SURE to adjust for part of year where USA goes to Daylight Savings but Asia remains on Standard time
input US_Bond_Close = 1500;
input Metals_Futures_Close = 1700;

#US
  AddVerticalLine(secondsFromTime(US_Open)[1] < 0 && secondsFromTime(US_Open) >= 0 and
                  Plot_Verticle_Line and 
                  Show_US, concat("US_Open", ""), Color.Green, curve.POINTS);
  AddVerticalLine(secondsFromTime(US_Close)[1] < 0 && secondsFromTime(US_Close) >= 0 and
                  Plot_Verticle_Line and 
                  Show_US, concat("US_Close", ""), Color.Green, curve.POINTS);
#AUD
   def AUDopen = if secondsFromTime(AUD_Open)[1] < 0 && 
                    secondsFromTime(AUD_Open) >= 0 
                 then barnumber() 
                 else AUDopen[1];
   def DataAUDopenLine = if barnumber()-1 == AudOpen 
                         then if IsNaN(barnumber()) 
                              then HighestAll(open[1]) 
                              else open[1] 
                         else DataAUDopenLine[1];

  AddVerticalLine(secondsFromTime(AUD_Open)[1] < 0 && 
                  secondsFromTime(AUD_Open) >= 0 and 
                  Plot_Verticle_Line and 
                  Show_Sydney, concat("AUD_Open", " "), Color.Yellow, curve.POINTS);

   def AUDclose = if secondsFromTime(AUD_Close)[1] < 0 && 
                    secondsFromTime(AUD_Close) >= 0 
                  then barnumber() 
                  else AUDclose[1];
   def DataAUDcloseLine = if barnumber()-1 == Audclose 
                          then if IsNaN(barnumber()) 
                               then HighestAll(close[1]) 
                               else close[1] 
                          else DataAUDcloseLine[1];
AddVerticalLine(secondsFromTime(AUD_Close)[1]<0 && secondsFromTime(AUD_Close) >=0 and
                Plot_Verticle_Line and 
                Show_Sydney, concat("AUD_Close",""),Color.Yellow, curve.POINTS);
# JPY
  AddVerticalLine(secondsFromTime(JPY_Open)[1] < 0 && 
                  secondsFromTime(JPY_Open) >= 0 and 
                  Plot_Verticle_Line and 
                  Show_Asian, concat("JPY_Open", ""), Color.Red, curve.POINTS);

  AddVerticalLine(secondsFromTime(JPY_Close)[1] < 0 && 
                  secondsFromTime(JPY_Close) >= 0 and 
                  Plot_Verticle_Line and 
                  Show_Asian, concat("JPY_Close", ""), Color.Red, curve.POINTS);
# GBP
  AddVerticalLine(secondsFromTime(GBP_Open)[1] < 0 && 
                  secondsFromTime(GBP_Open) >= 0 and 
                  Plot_Verticle_Line and 
                  Show_London, concat("GBP_Open", ""), Color.Blue, curve.POINTS);

  AddVerticalLine(secondsFromTime(GBP_Close)[1] < 0 && 
                  secondsFromTime(GBP_Close) >= 0 and 
                  Plot_Verticle_Line and 
                  Show_London, concat("GBP_Close", ""), Color.Blue, curve.POINTS);
# US Bond Close
  AddVerticalLine(secondsFromTime(US_Bond_Close)[1] < 0 && 
                  secondsFromTime(US_Bond_Close) >= 0 and 
                  Plot_Verticle_Line and 
                  Show_London, concat("US_Bond_Close", ""), Color.Plum, curve.POINTS);
# Metals Futures Close
  AddVerticalLine(secondsFromTime(Metals_Futures_Close)[1] < 0 && 
                  secondsFromTime(Metals_Futures_Close) >= 0 and 
                  Plot_Verticle_Line and 
                  Show_London, concat("Metal_Futs_Close", ""), Color.Orange, curve.POINTS);
# End Code
 

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

Hi MBF, I don't get here much lately. Use the format below as a template to put the Globex open / close on your chart.

Code:
# Time Reminders
AddVerticalLine(secondsTillTime(0930) == 0, "RTH", color.cyan, Curve.Short_Dash);
AddVerticalLine(secondsTillTime(1030) == 0, "End EU", color.cyan, Curve.Short_Dash);
AddVerticalLine(secondsTillTime(1200) == 0, "Lunch", color.cyan, Curve.Short_Dash);
AddVerticalLine(secondsTillTime(1500) == 0, "Lst Hr", color.cyan, Curve.Short_Dash);
AddVerticalLine(secondsTillTime(1615) == 0, "RTH End", color.cyan, Curve.Short_Dash);
 
Hello. I am new to ThinkScript, but hardly new to programming (30+ years).

I want to draw a collection of vertical lines, separated by a user-defined number of days, that can be placed on a day chart and dragged to different locations on that chart.

For example, I want to draw a vertical line at 9 days, 19 days, 43 days, and 65 days starting from an arbitrary, dragable point. The relative position of each would be a parameter in the scripts (using the Input keyword). In effect, I want to create a drawing surface that can be moved, and on that surface draw vertical lines (using, I suppose, the AddVerticalLine function).

Is this possible? If so, can someone please point me to a tutorial or example that might help me get started? Thanks in advance for all suggestions.
 
Thanks. I had no idea that there was a built-in drawing tool that does this. I will investigate more. And thanks also for the link; I will check that out, as well. It seems that what I want is really a new drawing tool. Drawing tools place their lines on a movable canvas that can be moved independently from the chart. I don't see a way to create one programatically.
 
This paints a vertical line 10 from the right hand side. Not 10 from the last bar with a value (be careful if you have an expansion area)
Code:
declare upper;

def t_bars = highestAll(barNumber());

addVerticalLine(barNumber() == t_bars - 10, "-10", color.lime);

-mashume
 
Greetings team,

Could someone show me how I could create a script to paint a horizontal line at the close of bar at a certain time of the day?

For example, to see a horizontal line painted at the close of a 5min bar at 10:30AM everyday.

Its the time element that is confusing me.

Thanks in advance.
 
I would like a label 10 minutes before the following AddVerticalLine time. The Label can simple read "10 Min Before Reversal"

Code:
AddVerticalLine(SecondsTillTime(1010) == 0, “R”, Color.DARK_GRAY, Curve.FIRM);
 
Thanx for the reply...but what about a singular vertical line just for purposes of marking reference period on the chart?
Here is some example code to help you along... For more information, check out the AddVerticalLine() function in the Learning Center...

Ruby:
input Start = 0930;
input End = 1600;
def StartTime = SecondsFromTime(Start) == 0;
def EndTime = SecondsFromTime(End) == 0;
AddVerticalLine(StartTime, "Start", Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(EndTime, "End", Color.GREEN, Curve.SHORT_DASH);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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