Is it possible to plot vertical lines on a daily chart for X days intervals? For example, plot a vertical line every 20 days?
Ruby:input start = 20211116; def xdays = 20; def bn = if GetYYYYMMDD() >= start then bn[1] + 1 else bn[1]; AddVerticalLine(if bn < 1 then Double.NaN else bn == 1 or !(bn % xdays), "", color = Color.YELLOW, stroke = Curve.FIRM);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
You requested this on a 'daily chart' setting. Daily charts do not have a time element. Are you wanting this on an intraday chart?that real close, now can it start at s specific time period like 9:30 est, thanks for your working on this
YesYou requested this on a 'daily chart' setting. Daily charts do not have a time element. Are you wanting this on an intraday chart?
Ruby:input startdate = 20220101; input starttime = 0930; def xdays = 5; def bn = if GetYYYYMMDD() >= startdate and SecondsFromTime(starttime) == 0 then 1 else if bn[1] >= 1 then bn[1] + 1 else bn[1]; def y = if bn[1] == 1 then y[1] + 1 else y[1]; AddVerticalLine( if bn < 1 then Double.NaN else y == 0 or !(y % xdays) and SecondsFromTime(starttime) == 0, "", Color.YELLOW, Curve.FIRM);
Is it possible to change this to minutes? And the start time could be set manually. I'm working on, I think, a breakthrough strategy with a friend, but it's somewhat subjective so the overall strategy can't be quantified. However, it's imperative to be able to set up vertical lines at a certain candle on the minute chart and then also set the amount of time to the next line. So some days it might be 445 am for 13 minutes... and sometimes it's 615 am for 22 minutes...Make sure that the time you enter is on the chart where you are using the code. Example, 9am start on a 1hr chart, when most start at 9:30am.
I changed the default to 5 days for testing in the following code.
Is it possible to change this to minutes? And the start time could be set manually. I'm working on, I think, a breakthrough strategy with a friend, but it's somewhat subjective so the overall strategy can't be quantified. However, it's imperative to be able to set up vertical lines at a certain candle on the minute chart and then also set the amount of time to the next line. So some days it might be 445 am for 13 minutes... and sometimes it's 615 am for 22 minutes...
Thanks!
And if you want to know the strategy, I'll fill you guys in when I get some examples, but it's a massive pain putting in all the vertical lines.... you can manually put it in everyday, say to add the date and time .. because I'll have to do it every day, since it is an intraday only strategy.
Code:#UT_Find_Time_on_Chart_xMinutes_from_Start input starttime = 0935; input xminutes = 92; input show_vertical = yes; input show_bubble = yes; def bar = BarNumber(); def b = if SecondsFromTime(starttime)[1] < 0 and SecondsFromTime(starttime) >= 0 then bar + Round(xminutes / (GetAggregationPeriod() / 60000), 0) else b[1]; input timezone = {default "ET", "CT", "MT", "PT"}; def starthour = (if timezone == timezone."ET" then 9 else if timezone == timezone."CT" then 8 else if timezone == timezone."MT" then 7 else 6) ; def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60); def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60; AddVerticalLine(show_vertical and bar == HighestAll(b) , " " + if show_bubble then "" else hour + ":" + (if minutes < 10 then "0" else "" ) + minutes, Color.YELLOW, Curve.FIRM); AddChartBubble( show_bubble and bar == HighestAll(b) , lowest(low, xminutes), hour + ":" + (if minutes < 10 then "0" else "" ) + minutes, Color.YELLOW, no);
This will find the time on a minute chart based upon the starttime and xminutes inputs. It will work on other chart timeframes, but will only be able to find the closest time to that on the minute chart basis.
View attachment 20657
Thanks for the help. I appreciate it. This is what I got... I set it to 500 and 18 minutes... It shows 502 one line... nothing after that... I need not only it starting time, but then 18 minute intervals afterwards... so every 18 minutes after 500 it will print a line... like the red and blue ones... is that possible?
Code:# Vertical_Lines_Starting_at_Date/Time_and_Minutebars_Interval # For Use on Minute Charts Only input datebegin = 20240109; input timebegin = 0500; input minutebars = 18; def barStart = if getyyyYMMDD() == datebegin and SecondsfromTime(timebegin)[1] < 0 and SecondsFromTime(timebegin) >= 0 then barnumber() else double.nan; def barcount = if SecondsTillTime(timebegin) == 0 and SecondsFromTime(timebegin) == 0 then 0 else barcount[1] + 1; AddVerticalLine(visible = BarNumber() >= HighestAll(barstart) and (barcount) % (minutebars / (GetAggregationPeriod() / 60000)) == 0, color = Color.WHITE);
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.