#### TonXas

##### New member

How do I incorporate the average type function into my averages? I tried changing

`def HSMA2 = average(dayHigh[-displace], length2);`

to `def HSMA2 = averagetype(dayHigh[-displace], length2);`

and that didnt work.
Code:

```
input aggregationPeriod = AggregationPeriod.Four_hours;
def len = 2;
input length2 = 2;
input length5 = 5;
input length10 = 10;
input displace = 0;
input averagetype = {default Wilders, EMA, sma, Hull};
def dayHigh = DailyHighLow(aggregationPeriod, len, 0, no).dailyhigh;
def dayLow = DailyHighLow(aggregationPeriod, len, 0, no).DailyLow;
def Dayopen = open(period = aggregationPeriod);
def na = Double.NaN;
def HSMA2 = average(dayHigh[-displace], length2);
def LSMA2 = Average(dayLow[-displace], length2);
def ADR2 = (HSMA2[1] - LSMA2[1]);
def HSMA5 = Average(dayHigh[-displace], length5);
def LSMA5 = Average(dayLow[-displace], length5);
def ADR5 = (HSMA5[1] - LSMA5[1]);
def HSMA10 = Average(dayHigh[-displace], length10);
def LSMA10 = Average(dayLow[-displace], length10);
def ADR10 = (HSMA10[1] - LSMA10[1]);
plot adr_sma_H2 = Dayopen + ADR2 / 2;
plot adr_sma_L2 = Dayopen - ADR2 / 2;
plot adr_sma_H5 = Dayopen + ADR5 / 2;
plot adr_sma_L5 = Dayopen - ADR5 / 2;
plot adr_sma_H10 = Dayopen + ADR10 / 2;
plot adr_sma_L10 = Dayopen - ADR10 / 2;
```

Last edited by a moderator: