Why would this study's indicator disappear when I disable after hours but reappear when I re enable AH?

Mr_Wheeler

Active member
I found this script to be what I was looking for as I don't like after hours being enabled because it makes my studies inaccurate. The problem is that the study goes away when I toggle off after & pre-market hours.

qIfXaei.png



The Source of the following code.

https://usethinkscript.com/threads/addverticalline-for-market-open-close-in-thinkscript.1346/

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
 
Solution
I found this script to be what I was looking for as I don't like after hours being enabled because it makes my studies inaccurate. The problem is that the study goes away when I toggle off after & pre-market hours.

qIfXaei.png



The Source of the following code.

https://usethinkscript.com/threads/addverticalline-for-market-open-close-in-thinkscript.1346/

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...
I found this script to be what I was looking for as I don't like after hours being enabled because it makes my studies inaccurate. The problem is that the study goes away when I toggle off after & pre-market hours.

qIfXaei.png



The Source of the following code.

https://usethinkscript.com/threads/addverticalline-for-market-open-close-in-thinkscript.1346/

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

the first step is to try to make it work, even if it isn't exactly as you want. if you can do this, then try to understand what will be needed to make it work correctly.

experiment with different start and stop times.
try 0900 and 1500. do the lines show up?

i think this part, [1], of the formula is causing a problem.
AddVerticalLine(secondsFromTime(US_Open)[1] < 0 &&

1600 (4pm) does not occur during normal trading hours. so you may have to figure out the last bar of the day.

https://usethinkscript.com/threads/finding-the-first-and-last-bar-of-the-day-in-thinkorswim.526/
 
Solution

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

the first step is to try to make it work, even if it isn't exactly as you want. if you can do this, then try to understand what will be needed to make it work correctly.

experiment with different start and stop times.
try 0900 and 1500. do the lines show up?

i think this part, [1], of the formula is causing a problem.
AddVerticalLine(secondsFromTime(US_Open)[1] < 0 &&

1600 (4pm) does not occur during normal trading hours. so you may have to figure out the last bar of the day.

https://usethinkscript.com/threads/finding-the-first-and-last-bar-of-the-day-in-thinkorswim.526/

I'm sorry. I couldn't get the closing time to work no matter even if i placed the closing time at noon. I've adjusted the the AM by moving the time ahead by 1 minute and that worked for me.

Now that I cleared my head I found that the closing time vertical line is irrelevant with the AM & PM markets when you've disabled those trading hours from showing up on your chart. I know it's not elegant but hey, it works. Only down side is that if you have the AH&PM enabled the vertical line is moved over a bit which is annoying for my OCD.

I

H4OKkEF.png
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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