#### MatthewA

##### Active member

Hey sometimes we get sick of adjusting the default chart aggregations and the lengths of the bars that we want a period to count as...

So I give you guys this Chart Label!

It only shows rounding up to the next largest time aggregation in a label but in just a few minutes you can make it switch the selected aggregation automatically for you Thank You All @Pelonsax

So I give you guys this Chart Label!

It only shows rounding up to the next largest time aggregation in a label but in just a few minutes you can make it switch the selected aggregation automatically for you Thank You All @Pelonsax

Code:

```
declare upper;
def ChartTime = (GetAggregationPeriod()/60000);
def NAN= Double.NAN;
addLabel(1, ChartTime + "Minutes");
def AggregationTableValue = if ChartTime>0 && ChartTime<=1 then 1 else if ChartTime>=1 && ChartTime<2 then 2 else if ChartTime>=2 && ChartTime<3 then 3 else if chartTime>= 4 && ChartTime<5 then 5 else if chartTime>= 5 && ChartTime<10 then 10 else if ChartTime>=10 && ChartTime<15 then 15 else if ChartTime>=15 && ChartTime<20 then 20 else if ChartTime>=20 && ChartTime<30 then 30 else if ChartTime>=30 && ChartTime<60 then 60 else if ChartTime>=60 && ChartTime<120 then 120 else if ChartTime>=120 && ChartTime<240 then 240 else if ChartTime>=240 && ChartTime<1440 then 1440 else if ChartTime>=1440 && ChartTime<2880 then 2880 else if ChartTime>=2880 && ChartTime<4320 then 4320 else if ChartTime>=4320 && ChartTime<5760 then 5760 else if ChartTime>=5760 && ChartTime< 10080 then 10080 else if ChartTime>= 10080 then 43200 else NAN ;
addLabel(1, AggregationTableValue + "MinimumMinutes");
#### Now all you have to do is use the minute value from AggregationTableValue to change what you assign for a multiTime Aggregation or what you might choose to assign for a period length like
#MACDshortlenght= {default 12, }...
#switch(ShorterLength) {
#Case 12:
#period =12; This is an exaggeration and you probably don't want this as your MACD but you can plug in any lengths you like here...
```

Last edited by a moderator: