Do I need to change the timezone in ThinkorSwim?

ezrollin

Member
VIP
Everytime I get code from someone else, I notice its coded in the Eastern Time zone. So I automatically change the times to my Central Time. Is ThinkScript hard coded to only deal with Eastern, so I'm messing the script up? Or does it just matter on the individual script? Or is it based on whatever your computer is set to?

Thanks
 

BenTen

Administrative
Staff member
Staff
VIP
ThinkorSwim operates via eastern time.

For example, the ORB script here. It starts at 930 (regular market hours) and ends at 1000 (30 mins after the market opens). Although I'm from the West Coast, I don't change 930 to 630. The opening time remains the same.

I hope that helps.

Just to be sure, you should always include the specific indicator in question.
 

Tony Stark

New member
hey everyone, question if my chart's x axis is currently propagating in Eastern timezone would I use military time in code for "CloseTime" or I would use Eastern time always?

example:

Code:
input CloseTime = 1600;
input DurationHours = 1;

def durationSec = DurationHours * 60 * 60;
def secondsRemained = SecondsTillTime(closeTime);

plot Price = if secondsRemained >= 0 and secondsRemained <= durationSec then close else double.NaN;

I think I answer my question, the SecondsTillTime Returns the number of seconds till the specified time (24-hour clock notation) in the EST timezone
 

rad14733

Well-known member
VIP
You are correct... New York Stock Exchange, located in New York City, is within the Eastern Standard Time Zone so all securities times are based on EST... That is the center of the financial universe...
 

BenTen

Administrative
Staff member
Staff
VIP
ThinkorSwim will always use EST time for their script. You can change your platform's timezone, but that shouldn't affect the time input in your indicator. I hope that makes sense.
 

Tony Stark

New member
i try this & still nothing

input OpenTime = 0400;
input DurationHours = 1;
def durationSec = DurationHours * 60 * 60;
def secondsPassed = SecondsFromTime(OpenTime);
plot Price = if secondsPassed >= 0 and secondsPassed <= durationSec then close else Double.NaN;
 

Tony Stark

New member
I have been able to get 4 clock, but it gives me 4 clock every day and I need only the 4pm once a week, any suggestions, ty! My code below:

input OpenTime = 1600;
input DurationHours = .25;
def durationSec = DurationHours * 60 * 60;

def secondsPassed = SecondsFromTime(OpenTime);
def rth = (RegularTradingEnd(GetYYYYMMDD()) - RegularTradingStart(GetYYYYMMDD())) / AggregationPeriod.WEEK;

plot Price = if secondsPassed >= 0 and secondsPassed <= durationSec then close else Double.NaN;
 

Tony Stark

New member
I don't know how to go about it from this point, everything in my code seems logical but now no plot even appears at all in any of the 4pm. Any help would be greatly appreciated.
Here's my progress:


declare hide_on_intraday;
input day_of_week = {default Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
input OpenTime = 1600;
input DurationHours = .25;
def durationSec = DurationHours * 60 * 60;

def secondsPassed = SecondsFromTime(OpenTime);
def rth = ((RegularTradingEnd(GetYYYYMMDD()) - (RegularTradingStart(GetYYYYMMDD()))) / (AggregationPeriod.WEEK));

plot Price = if secondsPassed >= 0 and secondsPassed <= durationSec and GetDayOfWeek(GetYYYYMMDD()) == day_of_week + 1 then close else Double.NaN;
 

Tony Stark

New member
Got it to work!
Here is the code to provided content:

input OpenTime = 1600;
input DurationHours = .25;
def durationSec = DurationHours * 60 * 60;

def secondsPassed = SecondsFromTime(OpenTime);
def rth = ((RegularTradingEnd(GetYYYYMMDD()) - (RegularTradingStart(GetYYYYMMDD()))) / (AggregationPeriod.WEEK));

plot Price = if secondsPassed >= 0 and secondsPassed <= durationSec and GetDayOfWeek(GetYYYYMMDD()) == 5 then close else Double.NaN;
 
Last edited:

Similar threads

Top