package ma1 import ( "github.com/banbox/banbot/config" "github.com/banbox/banbot/strat" "github.com/banbox/banstagy/com" ta "github.com/banbox/banta" ) /* 针对15m的参数 */ func MainV2(pol *config.RunPolicyConfig) *strat.TradeStrat { periodSml = 120 periodBig = 750 parentRate = 0.5 periodParBig = int(float64(periodBig) * parentRate) periodParSml = int(float64(periodSml) * parentRate) return &strat.TradeStrat{ Version: 1, WarmupNum: periodBig, MinTfScore: 0.75, //DrawDownExit: true, OnStartUp: onStartUp, OnPairInfos: com.MakePairInfos(sampleNum*sampleStep + periodParBig), OnInfoBar: onInfoMaCross, OnBar: func(s *strat.StratJob) { e := s.Env sml := ta.SMA(e.Close, 30) big := ta.SMA(e.Close, 70) x := sml.Cross(big) smaSml := ta.SMA(e.Close, periodSml) smaBig := ta.SMA(e.Close, periodBig) crx := smaSml.Cross(smaBig) more, _ := s.More.(*MoreType) if crx == 1 || crx == -1 { closeTag := "x_short" if crx < 0 { closeTag = "x_long" } _ = s.CloseOrders(&strat.ExitReq{ Tag: closeTag, Dirt: crx * -1, }) if crx == more.Dirt { // 交叉信号和大环境一致 more.open = crx //openTag := "long" //if crx < 0 { // openTag = "short" //} //_ = s.OpenOrder(&strategy.EnterReq{ // Tag: openTag, // Short: crx < 0, //}) } } x = -x if more.open != 0 && more.open == x { more.open = 0 openTag := "long" if x < 0 { openTag = "short" } _ = s.OpenOrder(&strat.EnterReq{ Tag: openTag, Short: x < 0, }) } }, //GetDrawDownExitRate: func(s *strategy.StratJob, od *ormo.InOutOrder, maxChg float64) float64 { // if maxChg > 3 { // return 0.2 // } else if maxChg > 1 { // return 0.25 // } else if maxChg > 0.5 { // return 0.3 // } // return 0 //}, } }