{"id":492,"date":"2017-02-22T02:43:45","date_gmt":"2017-02-22T02:43:45","guid":{"rendered":"http:\/\/www.patternsmart.com\/cn\/?p=492"},"modified":"2017-02-22T02:43:45","modified_gmt":"2017-02-22T02:43:45","slug":"three-types-of-aggregation-in-tos-charts-thinkscript","status":"publish","type":"post","link":"https:\/\/www.patternsmart.com\/cn\/three-types-of-aggregation-in-tos-charts-thinkscript\/","title":{"rendered":"three types of aggregation in TOS Charts thinkScript"},"content":{"rendered":"<p>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.<br \/>\nTime 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.<br \/>\nTick 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.<br \/>\nRange 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\u00ae (information on range charts is available <a href=\"https:\/\/tlc.thinkorswim.com\/center\/charting\/charts\/Aggregation-Types\/rangebars.html\" target=\"_blank\">here<\/a>).<br \/>\nAll 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 <a href=\"https:\/\/tlc.thinkorswim.com\/center\/charting\/thinkscript\/reference\/Constants\/AggregationPeriod.html\" target=\"_blank\">Aggregation Period<\/a> constant. You can also use a pre-defined string value for this purpose:<\/p>\n<div class=\"codeblock\">\n<div class=\"title\">Code:<\/div>\n<div class=\"body\" dir=\"ltr\"><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,<\/code><\/div>\n<\/div>\n<p>or<\/p>\n<div class=\"codeblock\">\n<div class=\"title\">Code:<\/div>\n<div class=\"body\" dir=\"ltr\"><code>&lt;current period&gt;<\/code><\/div>\n<\/div>\n<p>. Here is an example script:<\/p>\n<div class=\"codeblock\">\n<div class=\"title\">Code:<\/div>\n<div class=\"body\" dir=\"ltr\"><code>plot dailyOpen = open(period = AggregationPeriod.DAY);<\/code><\/div>\n<\/div>\n<p>This script plots daily Open price for the current symbol.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So far, we have learned many things about the bars on c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[71],"tags":[178,133,177,179,153],"class_list":["post-492","post","type-post","status-publish","format-standard","hentry","category-thinkorswim","tag-aggregation","tag-thinkorswim-tos","tag-thinkscript","tag-timeframe","tag-tos"],"_links":{"self":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/comments?post=492"}],"version-history":[{"count":1,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/492\/revisions"}],"predecessor-version":[{"id":493,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/492\/revisions\/493"}],"wp:attachment":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media?parent=492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/categories?post=492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/tags?post=492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}