Files
banstagy/trend/cci100.go
2026-08-24 20:53:21 +08:00

42 lines
966 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package trend
import (
"github.com/banbox/banbot/config"
"github.com/banbox/banbot/strat"
ta "github.com/banbox/banta"
)
/*
视频号:量化牛牛:CCI指标修改一个参数,“单车”变“汽车”
收益很不稳定,至少8H盈利。
*/
func CCI100(p *config.RunPolicyConfig) *strat.TradeStrat {
return &strat.TradeStrat{
WarmupNum: 100,
OnBar: func(s *strat.StratJob) {
e := s.Env
cci := ta.CCI(e.Close, 50)
cciN100 := cci.Cross(-100)
cciP100 := cci.Cross(100)
if len(s.LongOrders) > 0 {
if cciP100 == 1 {
// 上穿100,减仓
s.CloseOrders(&strat.ExitReq{Tag: "half", ExitRate: 0.5})
} else if cciP100 == -1 {
// 下穿100,平仓
s.CloseOrders(&strat.ExitReq{Tag: "exit"})
} else if cciN100 == -1 {
// 止损离场
s.CloseOrders(&strat.ExitReq{Tag: "stop"})
}
}
if cciN100 == 1 {
// 上穿-100,入场
s.OpenOrder(&strat.EnterReq{Tag: "long"})
}
},
}
}