Timestamp

Category: Date and time

The Timestamp function in ProBuilder language is used to retrieve the Unix timestamp of the closing time of a candlestick. A Unix timestamp represents the total number of seconds that have elapsed since the Unix Epoch (January 1st, 1970 at 00:00:00 UTC). This measurement is universal and does not vary regardless of geographical location.

Syntax:

Timestamp

Example Usage:

To calculate the number of seconds elapsed between the current bar and the first bar of the week, you can use the following script:

if dayofweek < dayofweek[1] then
    firstbarTime = Timestamp
endif
return Timestamp - firstbarTime as "elapsed seconds"

This script checks if the current day of the week is less than the day of the week of the previous bar (indicating the start of a new week). It then stores the timestamp of this first bar. Finally, it calculates the difference between the current bar's timestamp and this stored timestamp, returning the elapsed time in seconds.

Additional Information:

  • The Unix timestamp is particularly useful in financial analysis for measuring the exact time difference between events, which is crucial for time series analysis.
  • Understanding the concept of Unix timestamp is essential for handling date and time data accurately across different time zones and systems.

This function is a fundamental tool in ProBuilder for users needing precise time measurements between trading events or candlesticks.

Related Instructions:

  • CurrentTime date and time
  • OpenTime date and time
  • OpenTimestamp date and time
  • TIME date and time
  • Logo Logo
    Loading...