I just want a replica of the Stochastic indicator so I can optimize more than just the ‘K’ and ‘D’ I want to optimize the smoothing too.
There you go:
// https://en.wikipedia.org/wiki/Stochastic_oscillator
//
// settings for Stochastic 10,5,3)
Periods = 10
Kline = 5
Dline = 3
AvgType = 0 //Sma
K = average[Kline,AvgType](((close - lowest[Periods](low)) / (highest[Periods](high) - lowest[Periods](low))) * 100)
D = average[Dline,AvgType](K)
Return K AS "%K",D AS "%D"