How i get automatically n(Number of periods) in a exponential moving average

rstudio

#1

hi, i need help, can you help me ?
I make this code:
library(TTR)
library(pracma)
library(zoo)

#EMA
ema <- EMA(dataset$um, n = 10, wilder = FALSE, ratio = NULL)
dataset$EXPMEDIA=coredata(ema)

But i want the better n, How can I get the best value automatically?