time to seconds on a previous day

Questions about MultiCharts and user contributed studies.
jl12
Posts: 220
Joined: 29 Jun 2007
Has thanked: 10 times
Been thanked: 9 times
Contact:

time to seconds on a previous day

Postby jl12 » 15 Jan 2011

I would like to be able to calculate time in seconds from the current time to x bars back- where x bars may have occurred on a previous day. I am using range bars.

TimeToSeconds(time_s)-TimeToSeconds(time_s[xbars])

Is there a function that gives cumulative seconds from one session to another.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: time to seconds on a previous day

Postby TJ » 15 Jan 2011

I would like to be able to calculate time in seconds from the current time to x bars back- where x bars may have occurred on a previous day. I am using range bars.

TimeToSeconds(time_s)-TimeToSeconds(time_s[xbars])

Is there a function that gives cumulative seconds from one session to another.
"Time" is a tricky issue in programming,
not just in EasyLanguage, but in all programming endeavors.

This is a good primer on the ins-and-outs of time:
The TS Technologies EasyLanguage Reference Guide
CHAPTER: 2 - The Basic EasyLanguage Elements
Manipulating Dates and Times..... pg. 15

you can get the ebook here:
https://www.multicharts.com/multicharts ... mentation/

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: time to seconds on a previous day

Postby Dave Masalov » 20 Jan 2011

Is there a function that gives cumulative seconds from one session to another.
Dear jl12,

There is no such function, but you can write one. Something like this:

Code: Select all

variables: datetime1(0), datetime2(0), diff(0), in_seconds(0), xbars(0);

datetime1 = datetojulian(date) + eltimetodatetime_s(time_s);
datetime2 = datetojulian(date[xbars]) + eltimetodatetime_s(time_s[xbars]);

diff = datetime2 - datetime1;

in_seconds = intportion(diff)*24*60*60 + TimeToSeconds(datetime2eltime_s(diff));


Return to “MultiCharts”