EL time question

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

EL time question

Postby jl12 » 21 Feb 2012

I have been unable to workout out the syntax that gives time in seconds from the start of the day. Any suggestions would be welcome.

User avatar
TJ
Posts: 6518
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: EL time question

Postby TJ » 21 Feb 2012

jl12 wrote:I have been unable to workout out the syntax that gives time in seconds from the start of the day. Any suggestions would be welcome.

can you explain a bit more on what do you want to do? and what have you tried?


look up

TIME_s

User avatar
JoshM
Posts: 2074
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1523 times
Been thanked: 1479 times
Contact:

Re: EL time question

Postby JoshM » 22 Feb 2012

jl12 wrote:I have been unable to workout out the syntax that gives time in seconds from the start of the day. Any suggestions would be welcome.

Like TJ said, you need Time_s for this. You probably also want something like SessionStartTime() if you don't want to manually enter your start time for the first session of the bar. Then you'll need to convert these HHmmss and HHmm formats to a numerical format that makes it possible to calculate with time - DataTime conversion will take care of that.

Then you'll get something like the following:

Code: Select all

Variables:
   secondsSinceOpen(0), oneSecond(ELTimeToDateTime_s(1));
   
if (LastBarOnChart_s = True) then begin

   secondsSinceOpen = (ELTimeToDateTime_s(Time_s) - ELTimeToDateTime(SessionStartTime(0, 1))) / oneSecond;
   
   
   Print("Current time of bar: ", NumToStr(Time_s, 0), " Session open time: ", NumToStr(SessionStartTime(0, 1), 0), " seconds passed: ",
      NumToStr(secondsSinceOpen, 0));
   
end;


Which returns..

Code: Select all

Current time of bar: 215959 Session open time: 800 seconds passed: 50399


Which is correct, since (50399 / 60 seconds) / 60 minutes equals 13.9997222 hours, which is the time difference between the open at 8:00 and the current bar time of 21:59:59.
These users thanked the author JoshM for the post (total 2):
jl12furytrader

jl12
Posts: 197
Joined: 29 Jun 2007
Has thanked: 8 times
Been thanked: 8 times
Contact:

Re: EL time question

Postby jl12 » 22 Feb 2012

Thanks that's exactly what I was trying to do, "The ELTimeToDateTime_s(Time_s)" function was what I was missing


Return to “MultiCharts”