Definition and Purpose:
The OpenTimestamp function in ProBuilder language is designed to return the Unix timestamp corresponding to the opening time of the current candlestick. A Unix timestamp is a way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970 at UTC. Therefore, OpenTimestamp is crucial for strategies that require precise timing measurements between different events in the trading data.
OpenTimestamp
To calculate the number of seconds that have elapsed since the opening of the current candlestick, you can use the OpenTimestamp function in conjunction with the Timestamp function, which provides the current time’s Unix timestamp.
elapsed = Timestamp - OpenTimestamp
return elapsed
This code snippet will calculate the elapsed time in seconds from the opening of the current candlestick to the current time.