Join useThinkScript to post your question to a community of 21,000+ developers and traders.
I need help with adding a vertical line all across the chart with adjustable time and color for example every half hour or one hour a vertical line placement. I tried the TOS learning center but didn't succeed. Thanks
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 = 1200;
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"));
#@rlohmeyer
#TimeLines
input BarNo = 1;
input Plus = 15;
AddVerticalLine(barnumber() == barno,"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + plus ,"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 2),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 3),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 4),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 5),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 6),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 7),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 8),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 9),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 10),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 11),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 12),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 13),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 14),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 15),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 16),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 17),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 18),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 19),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 20),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 21),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 22),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 22),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 23),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 24),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 25),"",Color.white,curve.short_DASH);
AddVerticalLine(barnumber() == barno + (plus * 26),"",Color.white,curve.short_DASH);
If you figure out a better way, let me know. Thx, Bob
#Vertical Line at minutes interval
#Sleepyz
input minutes = 15;
input begin = 0930;
input end = 1600;
def bar = if SecondsTillTime(begin) == 0 and
SecondsFromTime(begin) == 0
then 0
else bar[1] + 1;
input showverticalline = yes;
AddVerticalLine(if showverticalline and SecondsFromTime(begin) >= 0 and secondsfromTime(end)<=0
then bar % (ceil(minutes) / (GetAggregationPeriod() / 60000)) == 0
else Double.NaN,
color = Color.BLUE, stroke = Curve.FIRM);
Here is another way you might find helpful
Code:#Vertical Line at minutes interval #Sleepyz input minutes = 15; input begin = 0930; input end = 1600; def bar = if SecondsTillTime(begin) == 0 and SecondsFromTime(begin) == 0 then 0 else bar[1] + 1; input showverticalline = yes; AddVerticalLine(if showverticalline and SecondsFromTime(begin) >= 0 and secondsfromTime(end)<=0 then bar % (ceil(minutes) / (GetAggregationPeriod() / 60000)) == 0 else Double.NaN, color = Color.BLUE, stroke = Curve.FIRM);
See if this helps. To meet your request, the times started were changed by using the 'script time'. Options are included to show vertical lines, alert, bubble, and/or label.Very useful study, thanks for sharing it @SleepyZ
Wondering if you could help add an audio alert & label that triggers 5 min before each new line is plotted. So for example, let´s say i use a 5min chart and have input minutes set to 60. Then i would like the audio alert to trigger at 11:55AM, 12:55PM, 1:55PM etc. and the label will show during this 5min window and then disappear after the crossing into new hour.
#Vertical Lines at minutes intervals, Alert, Label and Bubble Options
#Usethinkscript @zeek request
#Sleepyz
script time {
input minutes = 60;
input begin = 0930;
input end = 1600;
def bar = if SecondsTillTime(begin) == 0 and
SecondsFromTime(begin) == 0
then 0
else bar[1] + 1;
plot interval = if SecondsFromTime(begin) >= 0 and SecondsFromTime(end) <= 0
then bar % (Ceil(minutes) / (GetAggregationPeriod() / 60000)) == 0
else Double.NaN;
}
input showverticalline1 = yes;
AddVerticalLine(if showverticalline1
then time(60, begin = 900)
else Double.NaN,
"", Color.CYAN);
input showverticalline2 = yes;
AddVerticalLine(if showverticalline2
then time(60, begin = 855)
else Double.NaN,
"", Color.CYAN);
def duration = time(60, begin = 855);
input usealert = yes;
Alert(usealert and duration, "5 Minutes", Alert.BAR, Sound.Chimes);
input showlabel = yes;
AddLabel(showlabel and duration, "5 Minute Alert", Color.RED);
input showbubble = yes;
AddChartBubble(showbubble and IsNaN(close[-1]) and duration, high, "5 Minute Alert", Color.RED);
Plot Vertical Lines at specified time.
Code: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 = 1200; 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"));
Here is an example of code needed to be added for each alert, label you want:Hello @XeoNoX , nice study!
How can i add an audio alert and label for the line plots? Would like the alert & label to trigger 5min before plot and stay active until plot and then disappear. I tried adding the last lines of codes from post #49 but it doesn´t seem to work with your code. Would really appreciate if you can help me add this.
alert(istime(1155), "5 min ", alert.bar, sound.bell);
addlabel(istime(1155), "5 min ", color.red);
See if this helps. To meet your request, the times started were changed by using the 'script time'. Options are included to show vertical lines, alert, bubble, and/or label.
Code:#Vertical Lines at minutes intervals, Alert, Label and Bubble Options #Usethinkscript @zeek request #Sleepyz script time { input minutes = 60; input begin = 0930; input end = 1600; def bar = if SecondsTillTime(begin) == 0 and SecondsFromTime(begin) == 0 then 0 else bar[1] + 1; plot interval = if SecondsFromTime(begin) >= 0 and SecondsFromTime(end) <= 0 then bar % (Ceil(minutes) / (GetAggregationPeriod() / 60000)) == 0 else Double.NaN; } input showverticalline1 = yes; AddVerticalLine(if showverticalline1 then time(60, begin = 900) else Double.NaN, "", Color.CYAN); input showverticalline2 = yes; AddVerticalLine(if showverticalline2 then time(60, begin = 855) else Double.NaN, "", Color.CYAN); def duration = time(60, begin = 855); input usealert = yes; Alert(usealert and duration, "5 Minutes", Alert.BAR, Sound.Chimes); input showlabel = yes; AddLabel(showlabel and duration, "5 Minute Alert", Color.RED); input showbubble = yes; AddChartBubble(showbubble and IsNaN(close[-1]) and duration, high, "5 Minute Alert", Color.RED);
Hi,
I tried to change this to a 15minute time frame, but it doesn't work properly.
In the code below, I bolded the things that I changed...but unfortunately, it's still a no go.
Can someone please help with their expertise?
Thank you!
script time {
input minutes = 15
input begin = 0930;
input end = 1600;
def bar = if SecondsTillTime(begin) == 0 and
SecondsFromTime(begin) == 0
then 0
else bar[1] + 1;
plot interval = if SecondsFromTime(begin) >= 0 and SecondsFromTime(end) <= 0
then bar % (Ceil(minutes) / (GetAggregationPeriod() / 15000)) == 0
else Double.NaN;
Ruby:#Vertical Lines at minutes intervals, Alert, Label and Bubble Options #Usethinkscript @zeek request #Sleepyz script time { input minutes = 60; input begin = 0930; input end = 1600; def bar = if SecondsTillTime(begin) == 0 and SecondsFromTime(begin) == 0 then 0 else bar[1] + 1; plot interval = if SecondsFromTime(begin) >= 0 and SecondsFromTime(end) <= 0 then bar % (Ceil(minutes) / (GetAggregationPeriod() / 60000)) == 0 else Double.NaN; } input minutes = 15; input showverticalline1 = yes; AddVerticalLine(if showverticalline1 then time(minutes, begin = 930) else Double.NaN, "", Color.CYAN);
See if this helps.
This will plot a vertical line every 15 bars beginning at 930. Time is a script (like an indicator) that you use as shown in the code below where you define the inputs separately from the script. You can define them as was done with an input minutes = 15; or within time()) for the begin time changed to 0930.
Hi @SleepyZ - I just tried doing this, but unfortunately this didn't to show the lines every 15 minutes.
The first two lines after 9:30am are drawn at incorrect intervals, which throws off the subsequent lines on the day.
Do you have any other suggestions, please?
Thanks
Ruby:input show_verticallines = yes; defineGlobalColor("V",color.white); addverticalLine(show_verticallines and secondsFromTime(0930)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(0945)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1000)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1000+15*1)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1000+15*2)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1000+15*3)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1100)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1100+15*1)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1100+15*2)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1100+15*3)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1200)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1200+15*1)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1200+15*2)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1200+15*3)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1300)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1300+15*1)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1300+15*2)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1300+15*3)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1400)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1400+15*1)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1400+15*2)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1400+15*3)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1500)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1500+15*1)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1500+15*2)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1500+15*3)==0,"",globalColor("V")); addverticalLine(show_verticallines and secondsFromTime(1600)==0,"",globalColor("V"));
It is part of the addverticalline() function.Thanks again @SleepyZ !
one last things, please - how to make the vertical lines solid instead of dotted?
I tried a few different ways of doing it - such as .SetStyle(Curve.FIRM), but to no avail.
Any suggestions with this?
Ruby:input show_verticallines = yes; DefineGlobalColor("V", Color.WHITE); AddVerticalLine(show_verticallines and SecondsFromTime(0930) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(0945) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1000) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1000 + 15 * 1) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1000 + 15 * 2) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1000 + 15 * 3) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1100) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1100 + 15 * 1) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1100 + 15 * 2) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1100 + 15 * 3) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1200) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1200 + 15 * 1) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1200 + 15 * 2) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1200 + 15 * 3) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1300) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1300 + 15 * 1) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1300 + 15 * 2) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1300 + 15 * 3) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1400) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1400 + 15 * 1) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1400 + 15 * 2) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1400 + 15 * 3) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1500) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1500 + 15 * 1) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1500 + 15 * 2) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1500 + 15 * 3) == 0, "", GlobalColor("V"), Curve.FIRM); AddVerticalLine(show_verticallines and SecondsFromTime(1600) == 0, "", GlobalColor("V"), Curve.FIRM);
Unfortunately no, we have nothing like that on the forumAll 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
Here is an example of code needed to be added for each alert, label you want:
Code:alert(istime(1155), "5 min ", alert.bar, sound.bell); addlabel(istime(1155), "5 min ", color.red);
AddChartBubble(istime(1155), "5 min ", color.red);
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
W | Vertical Lines and times | Questions | 4 | |
Intra Day Trend Potential Vertical Lines & Shading | Questions | 2 | ||
vertical signal lines full chart | Questions | 3 | ||
B | Vertical Lines Peaks Alerts | Questions | 3 | |
C | Vertical Lines Indicator Needed | Questions | 1 |
Start a new thread and receive assistance from our community.
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.
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.