No complaint had been made to police.
Miles then went into the Whanganui police station and gave a DVD interview, admitting all his offending.
He also agreed to a further interview with police at a later date.
Justice Dobson said the offending happened in West Auckland, by Henderson Creek, which Miles told police was his "hunting ground".
The victims, who were children playing in the area, were aged 4 to 8 years old.
The abuse involved groping, digital violation and "oral contact". Justice Dobson also spoke of Miles stripping naked in front of children, and showing them pornography.
"The summary of facts is drawn almost entirely from your admissions," he said.
The court also heard Miles was sentenced to five years prison in 2013 for offending against another 4-year-old girl on whom he had committed indecent acts.
He also had her commit indecent acts on him.
Mr Ross outlined mitigating factors, including Miles' full confession and early guilty plea.
He said Miles was "being sentenced for offending that he admitted to that would not otherwise have been discovered".
Miles was willing to take part in treatment and rehabilitation programmes, and had also sought help for "deviant thoughts" while in prison and was taking medication.
"He has expressed remorse. He clearly knows without ever really thinking it through that sexual abuse does ruin people's lives," Mr Ross said.
Justice Dobson considered both a finite prison sentence and preventive detention, but did not feel a finite sentence would be enough to protect the community.
He described the offending as "chronic" and said Miles did not understand the "sources" of his offending, and would be a danger to society unless "physically or chemically constrained".
He sentenced Miles to preventive detention with a minimum of five years in prison.