This ProBuilder code snippet demonstrates how to access and display historical data from a different timeframe within the current chart’s timeframe. Specifically, it retrieves the date, open time, and close time of a candlestick from the 1-hour timeframe and displays this information in the current timeframe.
timeframe(1 hour, updateonclose) //save the candlestick date, open and close time in variable arrays
$candleDate[barindex]=date
$candleOpenTime[barindex]=OpenTime
$candleCloseTime[barindex]=time
timeframe(default) //get the 10th back 1-hour candlestick info
iindex = max(0,lastset($candleDate)-10)
idate = $candleDate[iindex]
iopen = $candleOpenTime[iindex]
iclose = $candleCloseTime[iindex]
return idate, iopen, iclose
The code snippet above is structured to perform the following steps:
timeframe(1 hour, updateonclose) function changes the chart’s timeframe to 1 hour for the purpose of data extraction. The updateonclose parameter ensures that the data is updated at the close of each 1-hour candlestick.$candleDate, $candleOpenTime, and $candleCloseTime. These arrays are indexed by barindex, which represents the current bar’s index in the 1-hour timeframe.timeframe(default) function resets the chart’s timeframe to the default setting, typically the timeframe that the chart was originally set to display.max(0, lastset($candleDate)-10). It then retrieves the date, open time, and close time for this specific candlestick using the calculated index.This example is useful for traders or analysts who need to compare or analyze data across different timeframes on the same chart.
Check out this related content for more information:
https://www.prorealcode.com/topic/recuperer-les-donnees-horaires-des-bougies/#post-145801
Visit Link