|
|
|
@ -5,20 +5,20 @@ import ( |
|
|
|
"sig-pub/pkg/types" |
|
|
|
"sig-pub/pkg/types" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Boll 布林带
|
|
|
|
// BOLL 布林带
|
|
|
|
type Boll struct { |
|
|
|
type BOLL struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *Boll) Meta() IndicatorMeta { |
|
|
|
func (c *BOLL) Meta() IndicatorMeta { |
|
|
|
return IndicatorMeta{ |
|
|
|
return IndicatorMeta{ |
|
|
|
Name: "Boll", |
|
|
|
Name: "BOLL", |
|
|
|
Input: []types.InputArg{ |
|
|
|
Input: []types.InputArg{ |
|
|
|
{Name: "window", Type: types.InputTypeUInt, Desc: "窗口大小"}, |
|
|
|
{Name: "window", Type: types.InputTypeUInt, Desc: "窗口大小"}, |
|
|
|
{Name: "pt", Type: types.InputTypeKPriceType, Desc: "k线序列类型"}, |
|
|
|
{Name: "pt", Type: types.InputTypePriceType, Desc: "k线序列类型"}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
State: []string{"ub", "lb"}, |
|
|
|
State: []string{"ub", "lb"}, |
|
|
|
Plots: []Plot{ |
|
|
|
Plots: []Plot{ |
|
|
|
{Name: "中轨", State: "vector", Type: PlotHistogram, Props: PlotProps{"color": ColorOrange}}, |
|
|
|
{Name: "中轨", State: "vector", Type: PlotLine, Props: PlotProps{"color": ColorOrange}}, |
|
|
|
{Name: "上轨", State: "ub", Type: PlotLine, Props: PlotProps{"color": ColorRed2}}, |
|
|
|
{Name: "上轨", State: "ub", Type: PlotLine, Props: PlotProps{"color": ColorRed2}}, |
|
|
|
{Name: "下轨", State: "lb", Type: PlotLine, Props: PlotProps{"color": ColorRed2}}, |
|
|
|
{Name: "下轨", State: "lb", Type: PlotLine, Props: PlotProps{"color": ColorRed2}}, |
|
|
|
{Name: "布林带阴影", State: "ub,lb", Type: PlotShadow, Props: PlotProps{"shadowColor": "rgba(241, 169, 166, 0.2)"}}, |
|
|
|
{Name: "布林带阴影", State: "ub,lb", Type: PlotShadow, Props: PlotProps{"shadowColor": "rgba(241, 169, 166, 0.2)"}}, |
|
|
|
@ -26,11 +26,11 @@ func (c *Boll) Meta() IndicatorMeta { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *Boll) CandlePeriods(ctx IIndicatorContext) int16 { |
|
|
|
func (c *BOLL) CandlePeriods(ctx IIndicatorContext) int16 { |
|
|
|
return ctx.Input().Int16("window") |
|
|
|
return ctx.Input().Int16("window") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *Boll) Calculate(ctx IIndicatorContext) (vector float64) { |
|
|
|
func (c *BOLL) Calculate(ctx IIndicatorContext) (vector float64) { |
|
|
|
window := ctx.Input().Int16("window") |
|
|
|
window := ctx.Input().Int16("window") |
|
|
|
pt := ctx.Input().PriceType() |
|
|
|
pt := ctx.Input().PriceType() |
|
|
|
priceSeries := ctx.Series(0, int16(window)).Price(pt) |
|
|
|
priceSeries := ctx.Series(0, int16(window)).Price(pt) |
|
|
|
|