You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
660 B

package indicator
import (
"sig-pub/pkg/types"
"github.com/markcheno/go-talib"
)
// todo macdSignal(信号线) macdHist(柱状图)
type MACD struct {
}
func (c *MACD) Name() string {
return "macd"
}
func (c *MACD) RequiredSeries(window int16, in types.Input) int16 {
return window
}
// Calculate 计算单根k线sma指标
func (c *MACD) Calculate(ctx IIndicatorContext, window int16) (vector float64) {
fast := ctx.Input().Int("fast")
slow := ctx.Input().Int("slow")
// 计算eam
closeSeries := ctx.Series(0, window).Close().Reverse()
aa, bb, cc := talib.Macd(closeSeries, fast, slow, int(window))
_, _, _ = aa, bb, cc
vector = 0
return
}