How do you Convert Time?


Category:
0
0
  1.  How do we create categories on the Q&A Forum.  I feel funny always posting my questions & comments under ScottTrade Migration,seems like I could create a category that would be more fitting, but it is a beginner  question.

I put in  GetTime() & get a  13 -digit #.  I want to convert it to something like   11:05 AM, Monday, Jan 9, 2018.  How do I do that?  I do not want to re-invent the wheel.  I get it. It is milliseconds form some time in 1970.

Basically, trying to  do something like this

def CurTime=GetTime();If CurTime> 9 PM each day and CurTime < 9PM each day + 11 hours or 8AM the next morning, then AssignBackgroundColor(Color.Gray) ;

So if anyone can give me a hint on a function that converts or some script lines that do that for me,then  I can get going.    Basically, just adding  Gray Transluscent Background to the times I am asleep on my chart study.

 

 

RESOLVED
Marked as spam
Posted by (Questions: 13, Answers: 18)
Asked on January 7, 2018 12:57 pm
1461 views
0

You don’t have the ability to create new categories. That is my job as the moderator. I scan each and every question and often move them to a more appropriate category when needed. For example I have moved this question into the “Chart Studies” category.

( at January 7, 2018 1:05 pm)
0

Thanks, I do not know where I would be w/o you. ThinkScript Support is 10 days getting back on email, and often tries to avoid answering questions. I wish I could give you more and intend to do so as this knowledge pays for itself. There is so much to TOS to learn. For other newbies, I came up with this code for my application which actually works.
# Time Section_______________________________________________________________
input DayTimeStart=1100; # 8AM PST
input NightTimeEnd=2359; # EST in 2400 -24 hr Clock time. 9PM PST

def CountfromStart=SecondsfromTime(DayTimeStart);
def CounttilEnd= Secondstilltime(NightTimeEnd);

def dayperiod=If(CountfromStart >0 && CounttilEnd >0,1,-1); # then 1 else 0;
#def sleepperiod= If((CountfromStart

( at January 15, 2018 10:24 am)
0

Excellent. Very glad you are able to find the resources you need here. Sorry to hear about lack of support from TD Ameritrade. The code you posted above is nearly identical to the code I posted in my answer on Jan 7th. Thanks for all your support.

( at January 15, 2018 1:14 pm)
0
Private answer

So what you want is to shade the background color of the chart based on a start time and end time. I think the best way to show this in action is to take a look at this video and examine the code provided with it: “Thinkorswim Overnight Range Scan Alert

There are two inputs at the very top of the code, alertPeriodStart and alertPeriodEnd.

We use those inputs to create a start counter and end counter:

def startCounter = SecondsFromTime(alertPeriodStart);
def endCounter = SecondsTillTime(alertPeriodEnd);

Then we combine those two into a single true/false variable that defines the alert period:

def alertPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;

Then we use that alertPeriod within our AddCloud() function:

AddCloud(if okToPlot and alertPeriod then Double.POSITIVE_INFINITY else Double.NaN, if okToPlot and alertPeriod then Double.NEGATIVE_INFINITY else Double.NaN, Color.YELLOW, Color.BLACK);

Notice this AddCloud() function also contains another variable named “okToPlot”. That’s actually one of the inputs we provide that allows the user to turn the shaded background on and off.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 7, 2018 1:13 pm