So far, we have learned many things about the bars on charts and values which can be calculated for them. But we never discussed the way they are formed (or, aggregated). In TOS Charts, three types of aggregation are available: time aggregation, tick aggregation, and range aggregation.
Time charts represent price action in terms of time: a new bar (or candlestick, line section, etc.) is plotted after completion of a certain time period (called aggregation period). For example, the 1y D bar chart plots the price action for one year, marking Open, High, Low, and Close prices on the daily basis.
Tick charts represent intraday price action in terms of quantity of trades: a new bar (or candlestick, line section, etc.) is plotted after completion of a certain number of trades (ticks). This aggregation type can be used on intraday charts with time interval not greater than five days. For example, the 2d 133t bar chart plots the price action for two days, defining Open, High, Low, and Close prices every time the number of trades becomes equal to 133.
Range charts represent price action in terms of price accumulation. Three modes of range aggregation are available in TOS Charts: Range Bars, Momentum Bars, and Renko Bars. However, these are not the subject of this chapter as we are going to discuss time aggregation in thinkScript® (information on range charts is available here).
All scripts we created before were the ones using aggregation period defined in chart settings. In order to access data of a different aggregation period in your code, specify the period parameter using the corresponding Aggregation Period constant. You can also use a pre-defined string value for this purpose:

Code:
1 min, 2 min, 3 min, 4 min, 5 min, 10 min, 15 min, 20 min, 30 min, 1 hour, 2 hours, 4 hours, Day, 2 Days, 3 Days, 4 Days, Week, Month, Opt Exp,

or

Code:
<current period>

. Here is an example script:

Code:
plot dailyOpen = open(period = AggregationPeriod.DAY);

This script plots daily Open price for the current symbol.

By admin

2 thoughts on “three types of aggregation in TOS Charts thinkScript”
  1. The above info is helpful but doesn’t go far enough for me. Could some one please explain what the script coding would be to create chart indicators for a 55 tick chart-which is 1 bar or candle
    graphed for every 55 trades. Being a newcomer to using ThinkScript, it appears there is code for any time frame beginning at 1 min.
    Is there a way to set the script text to chart a candle and indicators for every 55 ticks or trades?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.