ChristianDeee
New member
hey guys im looking for a 10:30AM vertical line indicator, wondering if anyone has one.
hey guys im looking for a 10:30AM vertical line indicator, wondering if anyone has one.
hey guys im looking for a 10:30AM vertical line indicator, wondering if anyone has one.
declare lower;
declare hide_on_daily;
#def period = aggregationPeriod.dAY;
def startTime = 0930;
input studyTime1 = 1045;
#AddVerticalLine(!period and SecondsFromTime(time)==0*60*60,"6:30",Color.LIME,Curve.SHORT_DASH);
AddVerticalLine(SecondsFromTime(startTime) == 0*60*60, " 9:30", Color.LIME, Curve.POINTS); #hint: 6:30 PST
AddVerticalLine(SecondsFromTime(startTime) == 0.5*60*60, " 10", Color.LIGHT_GRAY, Curve.POINTS); #hint: 7:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 1.5*60*60, " 11", Color.LIGHT_GRAY, Curve.POINTS); #hint: 8:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 2.5*60*60, "Lunch", Color.CYAN, Curve.POINTS); #hint: 9:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 3.5*60*60, " 1", Color.LIGHT_GRAY, Curve.POINTS); #hint: 10:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 4.5*60*60, " 2", Color.LIGHT_GRAY, Curve.POINTS); #hint: 11:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 5.5*60*60, " 3", Color.LIGHT_GRAY, Curve.POINTS); #hint: 12:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 6.5*60*60, " 4", Color.ORANGE, Curve.POINTS); #hint: 13:00 PST
# Convert military time hour to minute
def calcStartTime = (Round(startTime,-2)/100 + (startTime - Round(startTime,-2))/60)*60;
def calcStudyTime1 = (Round(studyTime1,-2)/100 + (studyTime1 - Round(studyTime1,-2))/60);
#def calcStudyMilitaryTime = AsText(Round(calcStudyTime1, 0)); #AsText(Round(price, 0))
#AddVerticalLine(SecondsFromTime(startTime) == 1*60*60, " " + calcStartTime + " " + calcStudyMarineTime, Color.YELLOW, Curve.FIRM);
AddVerticalLine(SecondsFromTime(startTime) == 1.25*60*60, " " + calcStudyTime1, Color.YELLOW, Curve.FIRM);
This will allow you to input time as 1045 and have the label output in the vertical line be 10:45 and plot the line at that time each day.@SleepyZ Unfortunately this is not the solution i'm looking for.
I'm looking for a user input time 10:45, and the script would then auto plot a vertical line along with the label 10:45 added. I don't want to manually calculate and manually change inside my script. It would be faster to use ToS and draw a vertical line
I think the hard part about this "unrewarding" script is manipulating the math part using thinkScript, which has limited functions that I can use to truncate decimal points and only keep the ones digit (something like def time = 10.75; truncate(time, 2). Looking to get an output = 10). I'll keep looking and hope someone with an answer and kind enough to give me a hint
Ruby:input time = 1045; def hour = Round(time / 100, 0); def minutes = ((time / 100) - hour) * 100; AddVerticalLine(SecondsFromTime(time) == 0, " " + hour + ":" + minutes, Color.WHITE, stroke = Curve.FIRM);
def Time935 = 9.583; #hint this is 9:35am
AddVerticalLine(SecondsFromTime(startTime) == 300, " 9:35" , Color.YELLOW, Curve.FIRM);
declare lower;
declare hide_on_daily;
def startTime = 0930;
# Time selection
def Time935 = 9.583; #hint this is 9:35am
def Time940 = 9.667;
def Time945 = 9.75;
input timeOptions = {default "None", "T935", "T940"};
def timeSlots = (
if timeOptions == timeOptions.T935 then Time935
else if timeOptions == timeOptions.T940 then Time940
else Time945
);
AddVerticalLine(SecondsFromTime(startTime) == 300, " 9:35" , Color.YELLOW, Curve.FIRM);
AddVerticalLine(SecondsFromTime(startTime) == 600, " 9:40" , Color.YELLOW, Curve.FIRM);
AddVerticalLine(SecondsFromTime(startTime) == 900, " 9:45" , Color.YELLOW, Curve.FIRM);
input time = 1055;
def hour = Round(time / 100, 0);
def minutes = ((time / 100) - hour) * 100;
AddVerticalLine(SecondsFromTime(time) == 0, " " + hour + ":" + minutes, Color.YELLOW, stroke = Curve.FIRM);
ok, i got things to work. Here is the complete script to add vertical lines from 2 ways: user input (PST) or select from a pull down (EST). Big thanks to @SleepyZ for the inspiration!Awesome @SleepyZ ! I spent 2 dayS trying to come up with this (math and logic) and you probably spent a few minutes with just 4 lines of code respect!
When I input 1055, which the codes round up and becomes round(10.55, 0) = 11:45. So i used rounddown and that fixed the issue.
Also, I'm trying a new way to do this by selecting from a pre-calculated time list instead, but i dont know how to code/link the "Time935" variable to the "AddVerticalLine(SecondsFromTime(startTime) == 300, " 9:35" , Color.YELLOW, Curve.FIRM)"; line of code.
Link this:
to this:Code:def Time935 = 9.583; #hint this is 9:35am
Code:AddVerticalLine(SecondsFromTime(startTime) == 300, " 9:35" , Color.YELLOW, Curve.FIRM);
Please see the updated codes below:
Code:declare lower; declare hide_on_daily; def startTime = 0930; # Time selection def Time935 = 9.583; #hint this is 9:35am def Time940 = 9.667; def Time945 = 9.75; input timeOptions = {default "None", "T935", "T940"}; def timeSlots = ( if timeOptions == timeOptions.T935 then Time935 else if timeOptions == timeOptions.T940 then Time940 else Time945 ); AddVerticalLine(SecondsFromTime(startTime) == 300, " 9:35" , Color.YELLOW, Curve.FIRM); AddVerticalLine(SecondsFromTime(startTime) == 600, " 9:40" , Color.YELLOW, Curve.FIRM); AddVerticalLine(SecondsFromTime(startTime) == 900, " 9:45" , Color.YELLOW, Curve.FIRM); input time = 1055; def hour = Round(time / 100, 0); def minutes = ((time / 100) - hour) * 100; AddVerticalLine(SecondsFromTime(time) == 0, " " + hour + ":" + minutes, Color.YELLOW, stroke = Curve.FIRM);
declare lower;
declare hide_on_daily;
def startTime = 0930;
AddVerticalLine(SecondsFromTime(startTime) == 0, " 9:30", Color.LIME, Curve.POINTS); #hint: 6:30 PST
AddVerticalLine(SecondsFromTime(startTime) == 0.5*60*60, " 10", Color.LIGHT_GRAY, Curve.POINTS); #hint: 7:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 5400, " 11", Color.LIGHT_GRAY, Curve.POINTS); #hint: 8:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 9000, "Lunch", Color.CYAN, Curve.POINTS); #hint: 9:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 12600, " 1", Color.LIGHT_GRAY, Curve.POINTS); #hint: 10:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 16200, " 2", Color.LIGHT_GRAY, Curve.POINTS); #hint: 11:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 19800, " 3", Color.LIGHT_GRAY, Curve.POINTS); #hint: 12:00 PST
AddVerticalLine(SecondsFromTime(startTime) == 6.5*60*60, " 4", Color.ORANGE, Curve.POINTS); #hint: 13:00 PST
# Time (EST) selection from a list
def Time0000 = 0000;
def Time0945 = 0945;
def Time1000 = 1000;
def Time1015 = 1015;
def Time1030 = 1030;
def Time1045 = 1045;
def Time1100 = 1100;
def Time1115 = 1115;
def Time1130 = 1130;
def Time1145 = 1145;
def Time1200 = 1200;
def Time1215 = 1215;
def Time1230 = 1230;
def Time1245 = 1245;
def Time1300 = 1300;
input timeOptionsEST = {default "None",
"T0945",
"T1000",
"T1015",
"T1030",
"T1045",
"T1100",
"T1115",
"T1130",
"T1145",
"T1200",
"T1215",
"T1230",
"T1245",
"T1300"
};
def timeSlots = (
if timeOptionsEST == timeOptionsEST.T0945 then Time0945
else if timeOptionsEST == timeOptionsEST.T1000 then Time1000
else if timeOptionsEST == timeOptionsEST.T1015 then Time1015
else if timeOptionsEST == timeOptionsEST.T1030 then Time1030
else if timeOptionsEST == timeOptionsEST.T1045 then Time1045
else if timeOptionsEST == timeOptionsEST.T1100 then Time1100
else if timeOptionsEST == timeOptionsEST.T1115 then Time1115
else if timeOptionsEST == timeOptionsEST.T1130 then Time1130
else if timeOptionsEST == timeOptionsEST.T1145 then Time1145
else if timeOptionsEST == timeOptionsEST.T1200 then Time1200
else if timeOptionsEST == timeOptionsEST.T1215 then Time1215
else if timeOptionsEST == timeOptionsEST.T1230 then Time1230
else if timeOptionsEST == timeOptionsEST.T1245 then Time1245
else if timeOptionsEST == timeOptionsEST.T1300 then Time1300
else Time0000
);
AddVerticalLine(SecondsFromTime(timeSlots) == 0, "", Color.YELLOW, Curve.FIRM);
# Time (PST) user input
input time = 635;
def hour = RoundDown(time / 100, 0);
def minute = ((time / 100) - hour) * 100;
def hourPST = hour + 3;
def timePST = (hourPST + minute/100) * 100;
AddVerticalLine(SecondsFromTime(timePST) == 0, "", Color.YELLOW, stroke = Curve.FIRM);
i need a script that plots a vertical line at open . . . . and also one at the beginning of pre-market
but i need it to work on a 180d 30m chart, and ONLY plot the line for the Current day
I can only get it to plot vertical lines for every day . . .
thanks in advance
#Verticallines_Time_Input_Exists_or_Next_if_Missing
input ShowTodayOnly = yes;
input Time1 = 0400;
input Time2 = 0930;
AddVerticalLine(
if ShowTodayOnly and GetDay() != GetLastDay()
then Double.NaN
else if SecondsFromTime(Time1) == 0
then SecondsFromTime(Time1) == 0 and SecondsTillTime(Time1) == 0
else if SecondsFromTime(Time1) != 0
then (SecondsFromTime(Time1)[1] < 0 and SecondsFromTime(Time1) > 0) or
(SecondsfromTime(Time1) > 0 and SecondsfromTime(Time1)[1] > secondsfromTime(Time1))
else Double.NaN,
" PreMarket Open", Color.WHITE, Curve.FIRM);
AddVerticalLine(
if ShowTodayOnly and GetDay() != GetLastDay()
then Double.NaN
else if SecondsFromTime(Time2) == 0
then SecondsFromTime(Time2) == 0 and SecondsTillTime(Time2) == 0
else if SecondsFromTime(Time2) != 0
then (SecondsFromTime(Time1)[1] < 0 and SecondsFromTime(Time1) > 0) or
(SecondsfromTime(Time1) > 0 and SecondsfromTime(Time1)[1] > secondsfromTime(Time1))
else Double.NaN,
" Market Open", Color.WHITE, Curve.FIRM);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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.