Peter
01/17/2023, 9:36 AMclass SimpleMovingAverageStrategy {
private val period = 14
private val sma = SimpleMovingAverage()
fun calculateSignal(prices: List<Double>): String {
sma.setPeriod(period)
sma.setValues(prices.toDoubleArray())
val currentSMA = sma.getMean()
return if (prices.last() > currentSMA) {
"BUY"
} else {
"SELL"
}
}
}
Luke Armitage
01/17/2023, 10:07 AMyou were right about one thing, master. the [strategy] was [simple]
Peter
01/17/2023, 10:10 AM