GetAggregationPeriod

GetAggregationPeriod ();

Description

The GetAggregationPeriod function returns the current aggregation period in milliseconds for time charts, in ticks for tick charts, and in dollars for range charts. The aggregation period returned is:

  • For time charts: the amount of milliseconds required to complete one candle
  • For tick charts: the amount of ticks required to complete one candle
  • For range charts: the price range required to complete a range bar

On time charts, you can use this function in combination with the aggregation period constants; for more information on thinkScript constants, see the Constants section.

Note: For GetAggregationPeriod, aggregations 1 Day and 24 hours are the same, even though they may produce different results on the charts. For example, an equality check for daily aggregation GetAggregationPeriod() >= AggregationPeriod.DAY  will return true when applied to a 24-hour aggregation chart.

Example

input lengthIntraday = 20;
input lengthDaily = 10;
plot data;
if GetAggregationPeriod() < AggregationPeriod.DAY {
data = Average(close, lengthIntraday);
} else {
data = Average(close, lengthDaily);
}

This example script plots a simple moving average with a length that depends on the current aggregation period. If the current aggregation period is shorter than one day, then the script plots the average with the length equal to the lengthIntraday. For aggregation periods of one day and greater, it plots the average with the length equal to lengthDaily.

You may also like
時間圖表
就匯總而言,時間圖表可能是最受歡迎的圖表種類,這很明顯是因爲其製圖的算法。在時間圖表,過了一段時期後(稱匯總時段)會劃出一條新的柱條(或蠟燭,線段等)。舉例,一個匯總為1日的圖所顯示的柱條代表每...
百份比视图
百份比顯示是一個thinkorswim平台的功能,讓您以百分比觀看價格改變。它以之前的價格作參考,而不僅僅是一堆絕對值,這在評估價格變動時尤為有用。TOS平台有數種方法觀看價格百份比。 1. 圖表設置