mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
indicator: fix ewma2 initial value
This commit is contained in:
parent
0a5f31a80f
commit
e529a3271d
|
@ -19,6 +19,10 @@ func EWMA2(source Float64Source, window int) *EWMAStream {
|
|||
|
||||
func (s *EWMAStream) Calculate(v float64) float64 {
|
||||
last := s.slice.Last(0)
|
||||
if last == 0.0 {
|
||||
return v
|
||||
}
|
||||
|
||||
m := s.multiplier
|
||||
return (1.0-m)*last + m*v
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user