From 3581c1768c4d92bc1a06c1e2e3cd0b669c2da974 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 14 Oct 2021 14:22:07 +0800 Subject: [PATCH] fix SMA indicator value length check --- pkg/indicator/sma.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/indicator/sma.go b/pkg/indicator/sma.go index 1d3c0a7b6..ee87cb17c 100644 --- a/pkg/indicator/sma.go +++ b/pkg/indicator/sma.go @@ -24,6 +24,9 @@ type SMA struct { } func (inc *SMA) Last() float64 { + if len(inc.Values) == 0 { + return 0.0 + } return inc.Values[len(inc.Values)-1] }