Hello
I want to compare the date and time reported by the function MouseClickDateTime and the Last calculated bar time
How can I get the Julian date and time of the last compile bar
LastCalcJdate, will returned the Julian date of the last calculated bar but not the the minutes and second
A print of the Mouse click time of the last bar on chart returned these value
MouseClickDateTime = 41887.70831597
LastCalcJDate = 41887.00000000
I need the last portion
Any help appreciated
Martin
Getting Julian time of the last Compile bar [SOLVED]
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Getting Julian time of the last Compile bar [SOLVED]
With:How can I get the Julian date and time of the last compile bar
* `LastCalcJDate` for the integer part (you already got that ),
* `LastCalcSSTime` for the number of seconds passed since midnight, converted to DateTime with `ELTimeToDateTime_s(1)` to get the fractional part of the DateTime value.
I hope the code example below answers your question:
Code: Select all
Variables:
lastCalcDT(0),
timeDiff(0);
[ProcessMouseEvents = True]
once cleardebug;
if (MouseClickCtrlPressed) then begin
lastCalcDT = LastCalcJDate +
(LastCalcSSTime * // Returns number of seconds
ELTimeToDateTime_s(1)); // .. times the DateTime value of 1 second
timeDiff = ComputerDateTime - lastCalcDT;
Print("LastCalcTime: ", NumToStr(lastCalcDT, 10), Spaces(3),
"Pretty: ", FormatTime("HH:mm:ss", lastCalcDT),
FormatDate(" d-M-yyyy", lastCalcDT));
Print("Current time: ", NumToStr(ComputerDateTime, 10), Spaces(3),
"Pretty: ", FormatTime("HH:mm:ss", ComputerDateTime),
FormatDate(" d-M-yyyy", ComputerDateTime));
Print("Time difference: ", NumToStr(timeDiff, 10), Spaces(3),
"Pretty: ", FormatTime("HH:mm:ss", timeDiff),
FormatDate(" d-M-yyyy", timeDiff));
Print(NewLine,
"Time difference in milliseconds: ",
NumToStr( (timeDiff / ELTimeToDateTime_s(1)) * 1000, 0),
NewLine,
"Time difference in seconds: ",
NumToStr(timeDiff / ELTimeToDateTime_s(1), 0),
NewLine,
"Time difference in minutes: ",
NumToStr(timeDiff / ELTimeToDateTime(1), 0),
NewLine,
"Time difference in hours: ",
NumToStr(timeDiff / ELTimeToDateTime(100), 0));
end;
Gives as output:
Code: Select all
LastCalcTime: 41887.9166666667 Pretty: 22:00:00 5-9-2014
Current time: 41888.6728663310 Pretty: 16:08:55 6-9-2014
Time difference: 0.7561996644 Pretty: 18:08:550
Time difference in milliseconds: 65335651
Time difference in seconds: 65336
Time difference in minutes: 1089
Time difference in hours: 18