GetAggregationPeriod equivalent for multi-timeframe indicators

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #258156 quote
    thomas2004ch
    Participant
    Average

    By ThinOrSwim and TradingView they have such function to create multi-timeframe indicator.

    #258158 quote
    Nicolas
    Keymaster
    Master

    With time dependent timeframe, you can use the GETTIMEFRAME instruction that returns the current timeframe of the chart in seconds.

    Here is the link in the documentation: https://www.prorealcode.com/documentation/gettimeframe/

    There is no built-in instruction for non linear timeframe such as ticks or volumes. I will think of a coded workaround.

    #258169 quote
    Nicolas
    Keymaster
    Master

    To obtain the number of ticks in the current candle, we can use:

    if not isset($ticks[barindex]) then
    $ticks[barindex] = 0
    endif
    
    
    if islastbarupdate then
    $ticks[barindex]=$ticks[barindex]+1
    endif
    
    
    return $ticks[barindex] coloured(0,255,255) style(histogram)
    

    A minimum of 2 candles are needed to verify that the counter is correct, here a 20-tick chart.

    prorealtime-ticks-counter.png prorealtime-ticks-counter.png
    #258180 quote
    Nicolas
    Keymaster
    Master

    Below is the code that indicates the amount of volume in the candle; here is an example with a chart in 50-volumes per candlestick.

    if not isset($volumes[barindex]) then
    $volumes[barindex] = 0
    endif
    
    
    if islastbarupdate then
    diff=volume-$volumes[barindex]
    $volumes[barindex]=$volumes[barindex]+diff
    endif
    
    
    return $volumes[barindex] coloured("orchid") style(histogram,2)
    
    prorealtime-volumes-count-per-bar.png prorealtime-volumes-count-per-bar.png
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

GetAggregationPeriod equivalent for multi-timeframe indicators


Platform Support: Charts, Data & Broker Setup

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Nicolas
1 hour, 1 minute ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 02/17/2026
Status: Active
Attachments: 2 files
Logo Logo
Loading...