How to plot vertical lines at specific times selected in different colors 2 or more in one indicator
Ruby:input time1 = 0936; input time2 = 1001; DefineGlobalColor("Time1", Color.WHITE); AddVerticalLine(SecondsFromTime(time1) >= 0 and SecondsFromTime(time1)[1] <= 0, " time1", GlobalColor("Time1"), Curve.FIRM); DefineGlobalColor("Time2", Color.CYAN); AddVerticalLine(SecondsFromTime(time2) >= 0 and SecondsFromTime(time2)[1] <= 0, " time2", GlobalColor("Time2"), Curve.FIRM);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thanks that works perfectly, however when I tried the times that I want it show some displacement from the graphic hours......example I want to mark 10:00 am and 11:00 am but hours or lines are not over the hourly candle
Ruby:input time1 = 1000; input time2 = 1100; DefineGlobalColor("Time1", Color.WHITE); def x1 = SecondsFromTime(time1) == 0; def h1= if x1 then double.positiVE_INFINITY else double.nan; def l1= if x1 then double.negative_iNFINITY else double.nan; addchart(h1,l1,0,0,chartType.cANDLE, GlobalColor("Time1")); DefineGlobalColor("Time2", Color.CYAN); def x2 = SecondsFromTime(time2) == 0; def h2= if x2 then double.positiVE_INFINITY else double.nan; def l2= if x2 then double.negative_iNFINITY else double.nan; addchart(h2,l2,0,0,chartType.cANDLE, GlobalColor("Time2"));
.....And in the other hand and this is not related to this topic, I just want to mention, how impress and grateful I am of be part of this community and I am amazed of the grade of knowledgment and cooperation of the participants, at this point I also want to recommends it to my trader partners and thinking to buy the VIP membership when you give some special promotion, I think its value every single $...... Very thankful guys and keep this wonderful job up!!!!!!.......
Ruby:input time1 = 1000; input time2 = 1100; def c = close; def o = open; def x1w = SecondsFromTime(time1) == 0 and c; def h1w= if x1w then double.positiVE_INFINITY else double.nan; def l1w= if x1w then double.negative_iNFINITY else double.nan; addchart(h1w,l1w,0,0,chartType.cANDLE, color.white); def x1 = SecondsFromTime(time1) == 0 and c[-1]; def h1g= if c > o and x1 then double.positiVE_INFINITY else double.nan; def l1g= if c > o and x1 then double.negative_iNFINITY else double.nan; addchart(h1g,l1g,0,0,chartType.cANDLE, color.green); def h1r= if c < o and x1 then double.positiVE_INFINITY else double.nan; def l1r= if c < o and x1 then double.negative_iNFINITY else double.nan; addchart(h1r,l1r,0,0,chartType.cANDLE, color.red); def x2w = SecondsFromTime(time2) == 0 and c; def h2w= if x2w then double.positiVE_INFINITY else double.nan; def l2w= if x2w then double.negative_iNFINITY else double.nan; addchart(h2w,l2w,0,0,chartType.cANDLE, color.white); def x2 = SecondsFromTime(time2) == 0 and c[-1]; def h2g= if c > o and x2 then double.positiVE_INFINITY else double.nan; def l2g= if c > o and x2 then double.negative_iNFINITY else double.nan; addchart(h2g,l2g,0,0,chartType.cANDLE, color.green); def h2r= if c < o and x2 then double.positiVE_INFINITY else double.nan; def l2r= if c < o and x2 then double.negative_iNFINITY else double.nan; addchart(h2r,l2r,0,0,chartType.cANDLE, color.red);
Apparently there is a error in the code or in the TOS, and I think that problem is related to the first bar is only 30 minutes instead an hour, for that reason the lines are displaced 1 H, I mean the 10am bar actually is 11 am and 11 h bar is 12..... do you know how to correct this?????, the way that I found to overcome this is changing the hour of the bars by -1 but this is not correct in the graphic time axis
Here is the same chart and now the time is at the 1400 bar. The 1330 has changed to the color of the 1330 candle and the 1400 is white while it is developing.
They look correct to me in your pictureYes is ET no PT.....
https://tinypic.host/i/photo-2022-10-31-14-01-02.7o3La
This is the wrong bars for 10 AM and 11 AM
This picture is 900am and 1000 am. The first bar on a 1hr chart on TOS is 900amhttps://tinypic.host/i/3.706mS
This is the right bars for 10 AM and 11 AM but in TOS appears displaced
Hi, there, there is a way to adapt this wonderful code to be used in a mobile device......that would be amazing, for my strategy use in a portable or when I travel
Totally understand,Sorry, I do not use the mobile device. Perhaps someone else may assist you.
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.