# how to model NGARCH using 5min frequency data?

NGARCH model using 5-min High-frequency data in R

I wanted to analyze some 5 minute frequency data of stock market. My teacher asked me to use NGARCH to model, but I didn't know how to program.Here is the NGARCH code that I found in a book, usually the GARCH model has a significant effect only on low-frequency data.

 "Ngarch" <- function(rtn){
# Estimation of a non-symmertic GARCH, NGARCH(1,1), model.
# Assume normal innovations
# rtn: return series

glkn <- function(par){
glkn=0
ht=var(rtn)
T=length(rtn)
if(T > 40)ht=var(rtn[1:40])
at=rtn[1]-par[1]
for (i in 2:T){
ept=rtn[i]-par[1]
at=c(at,ept)
sig2t=par[2]+par[3]*ht[i-1]+par[4]*ht[i-1]*(at[i-1]/sqrt(ht[i-1])-par[5])^2
ht=c(ht,sig2t)
glkn=glkn + 0.5*(log(sig2t) + ept^2/sig2t)
}
glkn
}

# obtain initial estimates
mu=mean(rtn)
par=c(mu,0.01,0.8,0.01,0.7)
mm=optim(par,glkn,method="Nelder-Mead",hessian=TRUE)
low=c(-10,0,0,0,0)
upp=c(10,1,1,0.4,2)
#mm=optim(par,glkn,method="L-BFGS-B",hessian=T,lower=low,upper=upp)

par=mm$$par H=mm$$hessian
Hi = solve(H)
se=sqrt(diag(Hi))
tra=par/se

# compute the volatility series and residuals
ht=var(rtn)
T=length(rtn)
if(T > 40)ht=var(rtn[1:40])
at=rtn-par[1]
for (i in 2:T){
sig2t=par[2]+par[3]*ht[i-1]+par[4]*(at[i-1]-par[5]*sqrt(ht[i-1]))^2
ht=c(ht,sig2t)
}
sigma.t=sqrt(ht)

## Print the results
names(par) <- c(
"mu", "beta0", "beta1", "beta2", "theta"
)
cat(" ","\n")
cat("Estimation results of NGARCH(1,1) model:","\n")
print(rbind("Estimate"=par, "SE"=se, "t-ratio"=tra))

list(residuals=at,volatility=sigma.t)
}


Does the NGARCH model need to be combined with realized volatility? How can I improve the above code?