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?
 
Hey @SleepyZ

In addition to the chartlabel, can you also help me with the code for a chartbubble for the 5min alert above?
I tried myself by adding the code below but it doesn´t seem to work

Code:
AddChartBubble(istime(1155), "5 min ", color.red);

I modified your time3 definition and had this bubble display on the upper price panel.

Ruby:
#declare lower;
#Plot Vertical Lines at specified time
script IsTime {
    input time = 0000;
    plot IsTime = SecondsFromTime(time)[1] < 0 and SecondsFromTime(time) >= 0;
}

input time1 = 0700;
input time2 = 0930;
input time3 = 1155;
input time4 = 1400;

DefineGlobalColor("Time1", GetColor(1));
DefineGlobalColor("Time2", GetColor(1));
DefineGlobalColor("Time3", GetColor(5));
DefineGlobalColor("Time4", GetColor(5));

AddVerticalLine(IsTime(time1), Floor(time1 / 100) + ":" + AsText(time1 % 100, "%02.0f"), GlobalColor("Time1"));
AddVerticalLine(IsTime(time2), Floor(time2 / 100) + ":" + AsText(time2 % 100, "%02.0f"), GlobalColor("Time2"));
AddVerticalLine(IsTime(time3), Floor(time3 / 100) + ":" + AsText(time3 % 100, "%02.0f"), GlobalColor("Time3"));
AddVerticalLine(IsTime(time4), Floor(time4 / 100) + ":" + AsText(time4 % 100, "%02.0f"), GlobalColor("Time4"));

AddChartBubble(istime(time3), low, "5 min ", Color.RED, up = No);
 
I modified your time3 definition and had this bubble display on the upper price panel.
Thank you!(y)

I noticed the bubble stays on the screen, can this be modified so that it only stays visible during the 5min from trigger to new 5min candle open?
Just like the chartlabel does in your previous code
 
All great studies, but is it possible to display vertical lines on a given X time day chart. I would like to set x as a changeable number of day bars. These would match the Kihon Suchi series of numbers 9, 17, 26, 33, 42, 65, 76, 129, 172, 200, 257. These are use along with ichimoku to plot time price cycles. Thanks in advanced

not quite sure what you are asking for. is this close ?


draw vertical blue lines,
when the barnumber equals a,
kijun number with a factor and offset applied to it.
((n1*fac)+ offset -1)

Code:
# kijun_numbers_vertlines_0

# AddVerticalLine for Start and End Times in thinkScript
# Branch  Dec 23, 2019
# https://usethinkscript.com/threads/addverticalline-for-start-and-end-times-in-thinkscript.1346/page-2#post-87941
#  HDP  Jan 17, 2022   post#38

#  is it possible to display vertical lines on a given X time day chart.
#  I would like to set x as a changeable number of day bars.
#  These would match the Kijun Suchi series of numbers 9, 17, 26, 33, 42, 65, 76, 129, 172, 200, 257.
#  These are use along with ichimoku to plot time price cycles.

# https://2ndskiesforex.com/forex-strategies/ichimoku-number-theory-an-introduction/
# The 10 Numbers
# Although there were 3 basic numbers which underlie the entire set of Ichimoku numbers, there were 10 in all.  They are listed below;
# 9, 17, 26, 33, 42, 65, 76, 129, 172, 200, 257 


def bn = barnumber();

input start_bar = 1;
def sb = start_bar;
input number_factor = 1;
def fac = number_factor;
input show_barnumbers = no;
def sbn = show_barnumbers;

addlabel(1, "start bar " + sb, color.yellow);
addlabel(1, "Factor " + fac, color.yellow);

def n1 = 9;  #9
def n2 = 17;   #17
def n3 = n1+n2;    #26
def n4 = n2*2-1;   #33
def n5 = n1+n4;   #42
def n6 = n4*2-1;   #65
def n7 = n4+n5+1;   #76
def n8 = n6*2-1;   #129
def n9 = n5+n8+1;    #172
def n10 = 200;    #200
def n11 = 257;   #257


def x1 = (bn == ((n1*fac)+sb -1));
def x2 = (bn == ((n2*fac)+sb -1));
def x3 = (bn == ((n3*fac)+sb -1));
def x4 = (bn == ((n4*fac)+sb -1));
def x5 = (bn == ((n5*fac)+sb -1));
def x6 = (bn == ((n6*fac)+sb -1));
def x7 = (bn == ((n7*fac)+sb -1));
def x8 = (bn == ((n8*fac)+sb -1));
def x9 = (bn == ((n9*fac)+sb -1));
def x10 = (bn == ((n10*fac)+sb -1));
def x11 = (bn == ((n11*fac)+sb -1));

# (if sbn then ("Bn " + bn) else "")

input lines1 = no;
addverticalline(lines1 and x1, (if sbn then ("Bn " + bn) else "") + "   K-" + n1, color.cyan);
addverticalline(lines1 and x2, (if sbn then ("Bn " + bn) else "") + "   K-" + n2, color.cyan);
addverticalline(lines1 and x3, (if sbn then ("Bn " + bn) else "") + "   K-" + n3, color.cyan);
addverticalline(lines1 and x4, (if sbn then ("Bn " + bn) else "") + "   K-" + n4, color.cyan);
addverticalline(lines1 and x5, (if sbn then ("Bn " + bn) else "") + "   K-" + n5, color.cyan);
addverticalline(lines1 and x6, (if sbn then ("Bn " + bn) else "") + "   K-" + n6, color.cyan);
addverticalline(lines1 and x7, (if sbn then ("Bn " + bn) else "") + "   K-" + n7, color.cyan);
addverticalline(lines1 and x8, (if sbn then ("Bn " + bn) else "") + "   K-" + n8, color.cyan);
addverticalline(lines1 and x9, (if sbn then ("Bn " + bn) else "") + "   K-" + n9, color.cyan);
addverticalline(lines1 and x10, (if sbn then ("Bn " + bn) else "") + "   K-" + n10, color.cyan);
addverticalline(lines1 and x11, (if sbn then ("Bn " + bn) else "") + "   K-" + n11, color.cyan);

# -------------------------------------------
# alt method of drawing lines

#def x = if (
#bn == ((n1*fac)+sb -1) or
#bn == ((n2*fac)+sb -1) or
#bn == ((n3*fac)+sb -1) or
#bn == ((n4*fac)+sb -1) or
#bn == ((n5*fac)+sb -1) or
#bn == ((n6*fac)+sb -1) or
#bn == ((n7*fac)+sb -1) or
#bn == ((n8*fac)+sb -1) or
#bn == ((n9*fac)+sb -1)
#) then 1 else 0;

#def bn_n = if x then (bn + 1 - sb)/fac else 0;
# ((n1*fac)+sb -1)
#addverticalline(x, "   " + bn_n , color.cyan);
#

DQ6oVw6.jpg
 
Thank you!(y)

I noticed the bubble stays on the screen, can this be modified so that it only stays visible during the 5min from trigger to new 5min candle open?
Just like the chartlabel does in your previous code

Replace your bubble code with this.

Ruby:
def x = if SecondsFromTime(time3) == 0 then BarNumber() else Double.NaN;
def y = if SecondsFromTime(time4) == 0 then BarNumber() - 1 else Double.NaN;
def last = if !IsNaN(close[-1]) then BarNumber() else Double.NaN;

AddChartBubble(istime(time3), if Between(HighestAll(last + 1), HighestAll(x), HighestAll(y)) then low else Double.NaN, "5 min ", Color.RED, up = no);
 
not quite sure what you are asking for. is this close ?


draw vertical blue lines,
when the barnumber equals a,
kijun number with a factor and offset applied to it.
((n1*fac)+ offset -1)

Code:
# kijun_numbers_vertlines_0

# AddVerticalLine for Start and End Times in thinkScript
# Branch  Dec 23, 2019
# https://usethinkscript.com/threads/addverticalline-for-start-and-end-times-in-thinkscript.1346/page-2#post-87941
#  HDP  Jan 17, 2022   post#38

#  is it possible to display vertical lines on a given X time day chart.
#  I would like to set x as a changeable number of day bars.
#  These would match the Kijun Suchi series of numbers 9, 17, 26, 33, 42, 65, 76, 129, 172, 200, 257.
#  These are use along with ichimoku to plot time price cycles.

# https://2ndskiesforex.com/forex-strategies/ichimoku-number-theory-an-introduction/
# The 10 Numbers
# Although there were 3 basic numbers which underlie the entire set of Ichimoku numbers, there were 10 in all.  They are listed below;
# 9, 17, 26, 33, 42, 65, 76, 129, 172, 200, 257


def bn = barnumber();

input start_bar = 1;
def sb = start_bar;
input number_factor = 1;
def fac = number_factor;
input show_barnumbers = no;
def sbn = show_barnumbers;

addlabel(1, "start bar " + sb, color.yellow);
addlabel(1, "Factor " + fac, color.yellow);

def n1 = 9;  #9
def n2 = 17;   #17
def n3 = n1+n2;    #26
def n4 = n2*2-1;   #33
def n5 = n1+n4;   #42
def n6 = n4*2-1;   #65
def n7 = n4+n5+1;   #76
def n8 = n6*2-1;   #129
def n9 = n5+n8+1;    #172
def n10 = 200;    #200
def n11 = 257;   #257


def x1 = (bn == ((n1*fac)+sb -1));
def x2 = (bn == ((n2*fac)+sb -1));
def x3 = (bn == ((n3*fac)+sb -1));
def x4 = (bn == ((n4*fac)+sb -1));
def x5 = (bn == ((n5*fac)+sb -1));
def x6 = (bn == ((n6*fac)+sb -1));
def x7 = (bn == ((n7*fac)+sb -1));
def x8 = (bn == ((n8*fac)+sb -1));
def x9 = (bn == ((n9*fac)+sb -1));
def x10 = (bn == ((n10*fac)+sb -1));
def x11 = (bn == ((n11*fac)+sb -1));

# (if sbn then ("Bn " + bn) else "")

input lines1 = no;
addverticalline(lines1 and x1, (if sbn then ("Bn " + bn) else "") + "   K-" + n1, color.cyan);
addverticalline(lines1 and x2, (if sbn then ("Bn " + bn) else "") + "   K-" + n2, color.cyan);
addverticalline(lines1 and x3, (if sbn then ("Bn " + bn) else "") + "   K-" + n3, color.cyan);
addverticalline(lines1 and x4, (if sbn then ("Bn " + bn) else "") + "   K-" + n4, color.cyan);
addverticalline(lines1 and x5, (if sbn then ("Bn " + bn) else "") + "   K-" + n5, color.cyan);
addverticalline(lines1 and x6, (if sbn then ("Bn " + bn) else "") + "   K-" + n6, color.cyan);
addverticalline(lines1 and x7, (if sbn then ("Bn " + bn) else "") + "   K-" + n7, color.cyan);
addverticalline(lines1 and x8, (if sbn then ("Bn " + bn) else "") + "   K-" + n8, color.cyan);
addverticalline(lines1 and x9, (if sbn then ("Bn " + bn) else "") + "   K-" + n9, color.cyan);
addverticalline(lines1 and x10, (if sbn then ("Bn " + bn) else "") + "   K-" + n10, color.cyan);
addverticalline(lines1 and x11, (if sbn then ("Bn " + bn) else "") + "   K-" + n11, color.cyan);

# -------------------------------------------
# alt method of drawing lines

#def x = if (
#bn == ((n1*fac)+sb -1) or
#bn == ((n2*fac)+sb -1) or
#bn == ((n3*fac)+sb -1) or
#bn == ((n4*fac)+sb -1) or
#bn == ((n5*fac)+sb -1) or
#bn == ((n6*fac)+sb -1) or
#bn == ((n7*fac)+sb -1) or
#bn == ((n8*fac)+sb -1) or
#bn == ((n9*fac)+sb -1)
#) then 1 else 0;

#def bn_n = if x then (bn + 1 - sb)/fac else 0;
# ((n1*fac)+sb -1)
#addverticalline(x, "   " + bn_n , color.cyan);
#

DQ6oVw6.jpg
sorry for the long delay, I total forgot about it since my ideal was reject for not available. your study is pretty close. I just wanted a study to be at equal on the chart at X number of bars apart and that they would get all the same distance. But the distance could be changed in the setting, So say the Kihon Suchi patterns would start out with 9 bars apart, and then later in the day it would change to 26 bars apart, The pattern would be of the same number of bars until bar pattern wide or shorten in distance. I could then reset the bars to be 26 bars apart. That prior Bars is not important just the current setting forward in time until the pattern changes again. Thanks for your help and work on this
 
Any idea why the lines won't display with after hours untoggled? I found this script very helpful as I don't like displaying after hours because it messes up the accuracy of my other scripts.
 
Hey @SleepyZ

In addition to the chartlabel, can you also help me with the code for a chartbubble for the 5min alert above?
I tried myself by adding the code below but it doesn´t seem to work

Code:
AddChartBubble(istime(1155), "5 min ", color.red);

@zeek, just saw this request. Using your istime script from an earlier post with declare lower included, this will plot a bubble.
Ruby:
declare lower;
#Plot Vertical Lines at specified time
script IsTime {
    input time = 0000;
    plot IsTime = SecondsFromTime(time)[1] < 0 and SecondsFromTime(time) >= 0;
}

addverticalLine(istime(1155), "11:55");
AddChartBubble(istime(1155), 0, "5 min ", color.red, up = No);

If you remove the declare lower in the above code , making the bubble appear on the upper pane, then subtitute the zero (0) for some price location, for example, high:
Ruby:
AddChartBubble(istime(1155), high, "5 min ", color.red, up = No);
 
Has anyone created any ICT Killzones script which basically highlights Asia, London, NY sessions. I have seen one in Trading View - https://www.tradingview.com/script/nW5oGfdO-ICT-Killzones-Pivots-TFO/. Anyone have a similar version for TOS?


@samer800 Have you created any ICT Killzones script which basically highlights Asia, London, NY sessions. I have seen one in Trading View - https://www.tradingview.com/script/nW5oGfdO-ICT-Killzones-Pivots-TFO/. Wondering if you or anyone created a similar version for TOS?
 
Last edited by a moderator:
Has anyone created any ICT Killzones script which basically highlights Asia, London, NY sessions. I have seen one in Trading View - https://www.tradingview.com/script/nW5oGfdO-ICT-Killzones-Pivots-TFO/. Anyone have a similar version for TOS?


@samer800 Have you created any ICT Killzones script which basically highlights Asia, London, NY sessions. I have seen one in Trading View - https://www.tradingview.com/script/nW5oGfdO-ICT-Killzones-Pivots-TFO/. Wondering if you or anyone created a similar version for TOS?
Code:
input showlabels = yes;

#Asian
AddLabel(showlabels and SecondsFromTime(2000) >= 0 and SecondsTillTime(0000) > 0, "Zone 1", Color.GRAY);

#London
AddLabel(showlabels and SecondsFromTime(0200) >= 0 and SecondsTillTime(0500) > 0, "Zone 2", Color.DARK_GRAY);

#NYC
AddLabel(showlabels and SecondsFromTime(0800) >= 0 and SecondsTillTime(1100) > 0, "Zone 3", Color.DARK_GRAY);

#London Silver Bullet
#AddLabel(showlabels and SecondsFromTime(0245) >= 0 and #SecondsTillTime(0330) > 0, "Zone 4", Color.GRAY);


input showverticals = yes;

#Asian
AddVerticalLine(showverticals and SecondsFromTime(2000) == 0, "Asian", Color.GRAY);

AddVerticalLine(showverticals and SecondsFromTime(0000) == 0, "End", Color.GRAY);

#London

AddVerticalLine(showverticals and SecondsFromTime(0200) == 0, "London", Color.DARK_GRAY);

AddVerticalLine(showverticals and SecondsFromTime(0500) == 0, "Emd", Color.DARK_GRAY);


#NYC
AddVerticalLine(showverticals and SecondsFromTime(0800) == 0, "NYC", Color.GRAY);

AddVerticalLine(showverticals and SecondsFromTime(1200) == 0, "End", Color.GRAY);
 

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