what is the function to get the close time of N bar ago?

Questions about MultiCharts and user contributed studies.
martingale
Posts: 91
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

what is the function to get the close time of N bar ago?

Postby martingale » 30 Mar 2012

and if there's a function to get time length of the bar?

and if there's a way to get different in time between each 2 bars, say
Time[2]-Time[3] will give me how many minutes of each bar length.

but if Time[2] is 10:00AM, and Time[3] is 9:55am, it will only give 45 which is supposed to be 5 minutes not 45 minutes.

thanks
Last edited by martingale on 30 Mar 2012, edited 1 time in total.

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

Re: what is the function to get the close time of N bar ago?

Postby TJ » 30 Mar 2012

and if there's a function to get time length of the bar?

Can you describe your idea (and application) in more detail?

What kind of bar? From a minute chart? Tick chart?

Can you draw a diagram?

martingale
Posts: 91
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: what is the function to get the close time of N bar ago?

Postby martingale » 30 Mar 2012

and if there's a function to get time length of the bar?

Can you describe your idea (and application) in more detail?

What kind of bar? From a minute chart? Tick chart?

Can you draw a diagram?
1. let's say 3 minute bar, i'd like to find out how many time difference in minute is P bar ago and P-1 bar ago. i.e. Time[P-1] - Time[P] in terms of minutes
2. and trying to find a way to get time_span_of_current_bar, which is 3 minutes for each bar in my chart.

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

Re: what is the function to get the close time of N bar ago?

Postby TJ » 30 Mar 2012

and if there's a function to get time length of the bar?

Can you describe your idea (and application) in more detail?

What kind of bar? From a minute chart? Tick chart?

Can you draw a diagram?
1. let's say 3 minute bar, i'd like to find out how many time difference in minute is P bar ago and P-1 bar ago. i.e. Time[P-1] - Time[P] in terms of minutes
2. and trying to find a way to get time_span_of_current_bar, which is 3 minutes for each bar in my chart.

MultiCharts use End-of-Bar (EOB) time for chart time stamp.

You will need to use CURRENTTIME minus TIME[1] to find the time lapsed since bar start.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: what is the function to get the close time of N bar ago?

Postby JoshM » 31 Mar 2012

What TJ says, plus to add..
i'd like to find out how many time difference in minute is P bar ago and P-1 bar ago. i.e. Time[P-1] - Time[P] in terms of minutes
Can for example be done as following:

Code: Select all

Variables:
timeThisBar(0), timePrevBar(0), oneSecond(ELTimeToDateTime_s(1)), secondsInBar(0);

if (LastBarOnChart_s = True) then begin

timeThisBar = Time_s;
timePrevBar = Time_s[1];
secondsInBar= (ELTimeToDateTime_s(timeThisBar) - ELTimeToDateTime_s(timePrevBar)) / oneSecond;

Print("Time this bar: ", FormatTime("HH:mm:ss", ELTimeToDateTime_s(timeThisBar)), NewLine,
"Time previous bar: ", FormatTime("HH:mm:ss", ELTimeToDateTime_s(timePrevBar)), Newline,
"Seconds in bar: ", NumToStr(secondsInBar, 2));

end;
which returns:

Code: Select all

Time this bar: 21:59:59
Time previous bar: 21:59:35
Seconds in bar: 24.00


Return to “MultiCharts”