Time Vertical Lines - Inconsistent display on diff time frames

AndNow

New member
Hi all,
Using an already existing thinkScript to print vertical time lines, and to include labels, I was able to modify it so that it displays the three basic time points of the Ichimoku time theory approach (interval points at 9, 17, 26), and in terms of the 5 min intraday chart. It works very well on the 5 min chart, but not on 15min or others (where I would want it to make lines at the same time points as on the 5 min). See the images below. What am I missing in the thinkScript for it to work in 15 min, 1hr, etc. charts?
here is AA on 5 min (Fri, Oct 21, 22). the vertical time lines and labels are displayed correctly

Screen-Shot-2022-10-23-at-10-04-51-AM.png

https://postimg.cc/xq71PHBy

Here is AA on 15 min (Fri, Oct 21, 22). the vertical time lines and labels are not correct. Two are missing.

Screen-Shot-2022-10-23-at-10-06-01-AM.png

https://postimg.cc/K44nzPnn
This is the thinkScript:


input showlabels = yes;








AddLabel(showlabels and SecondsFromTime(0927) >= 0 and SecondsTillTime(0933) > 0, “Opening”, Color.YELLOW);


AddLabel(showlabels and SecondsFromTime(1012) >= 0 and SecondsTillTime(1018) > 0, “9”, Color.WHITE);


AddLabel(showlabels and SecondsFromTime(1052) >= 0 and SecondsTillTime(1058) > 0, “17”, Color.YELLOW);


AddLabel(showlabels and SecondsFromTime(1137) >= 0 and SecondsTillTime(1143) > 0, “26”, Color.WHITE);








input showverticals = yes;








AddVerticalLine(showverticals and SecondsFromTime(0930) == 0, “Opening”, Color.WHITE);


AddVerticalLine(showverticals and SecondsFromTime(1015) == 0, “9”, Color.WHITE);


AddVerticalLine(showverticals and SecondsFromTime(1055) == 0, “17”, Color.WHITE);


AddVerticalLine(showverticals and SecondsFromTime(1140) == 0, “26”, Color.WHITE);
 
It's a timeframe issue. '17' and '26' (10:55 and 11:40 in your code) aren't the start of a 15 min candle/bar so they will never evaluate to 0. On the 5 min chart they do start a 5 min candle/bar so they show. You'll have to either check what timeframe is being used and adjust accordingly or do some math work to auto-adjust based on values from SecondsFromTime.
 
Last edited:
And, If the labels aren't really needed then the simple solution is :

input showverticals = yes;

plot SFT1015 = if showverticals then secondsfromtime(1015) else double.Nan;
plot SFT1055 = if showverticals then secondsfromtime(1055) else double.Nan;
plot SFT1140 = if showverticals then secondsfromtime(1140) else double.Nan;
plot SFT0930 = if showverticals then secondsfromtime(0930) else double.Nan;
 
And, If the labels aren't really needed then the simple solution is :

input showverticals = yes;

plot SFT1015 = if showverticals then secondsfromtime(1015) else double.Nan;
plot SFT1055 = if showverticals then secondsfromtime(1055) else double.Nan;
plot SFT1140 = if showverticals then secondsfromtime(1140) else double.Nan;
plot SFT0930 = if showverticals then secondsfromtime(0930) else double.Nan;
thanks yeah! yeah i don't need the labels. i tried the simple solution but it shows like this... so something is off...

 
thanks yeah! yeah i don't need the labels. i tried the simple solution but it shows like this... so something is off...


You can try this. It assigns barnumbers starting at 0930 as 1 and thereafter increase by 1 throughout the reg trading hours. It then uses your barnumbers at the 5min agg and creates an adjustment for the other chart timeframes you may select. Since as Joe indicated, some of the times on the 5min chart do not exist on other chart timeframes, the code rounds the barnumbers using ceil', which rounds a value up to the nearest integer (which is not less than the value). It then substitutes those values for the 9, 17 and 27 barnumbers used on the 5min chart.

Screenshot-2022-10-23-160224.png
Ruby:
def bn    = BarNumber();
def rth   = SecondsFromTime(0930) >= 0 and SecondsFromTime(1600) < 0;
def rthbn = if SecondsFromTime(0930) == 0
            then 1
            else if rth
            then rthbn[1] + 1
            else Double.NaN;

input show_rth_barnumbers = no;
plot rthbarnumbers = rthbn ;
rthbarnumbers.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
rthbarnumbers.SetHiding(!show_rth_barnumbers);

input showverticals = yes;

def adj = GetAggregationPeriod() / AggregationPeriod.FIVE_MIN;

AddVerticalLine(if showverticals then rthbn == 1 else Double.NaN);
AddVerticalLine(if showverticals then rthbn == Ceil(9 / adj) else Double.NaN);
AddVerticalLine(if showverticals then rthbn == Ceil(17 / adj) else Double.NaN);
AddVerticalLine(if showverticals then rthbn == Ceil(27 / adj) else Double.NaN);
 
You can try this. It assigns barnumbers starting at 0930 as 1 and thereafter increase by 1 throughout the reg trading hours. It then uses your barnumbers at the 5min agg and creates an adjustment for the other chart timeframes you may select. Since as Joe indicated, some of the times on the 5min chart do not exist on other chart timeframes, the code rounds the barnumbers using ceil', which rounds a value up to the nearest integer (which is not less than the value). It then substitutes those values for the 9, 17 and 27 barnumbers used on the 5min chart.
Thank you. that's great!
 

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