gitee.com/quant1x/engine@v1.8.4/factors/feature_box_madx.go (about) 1 package factors 2 3 import ( 4 "gitee.com/quant1x/engine/utils" 5 "gitee.com/quant1x/pandas" 6 . "gitee.com/quant1x/pandas/formula" 7 ) 8 9 type JuXianDongXiang struct { 10 Dm0 float64 11 Dm1 float64 12 Dm2 float64 13 Diverging float64 14 B bool 15 //S bool 16 } 17 18 // 多空趋势 19 func computeJuXianDongXiang(OPEN, CLOSE, HIGH, LOW pandas.Series) *JuXianDongXiang { 20 //{均线动向, V1.0.3, 2023-09-18} 21 //P0:=3; 22 P0 := 3 23 //P1:=5; 24 P1 := 5 25 //P2:=10; 26 P2 := 10 27 //P3:=20; 28 P3 := 20 29 //MX:=CLOSE; 30 MX := CLOSE 31 //MA0:=MA(MX,P0); 32 MA0 := MA(MX, P0) 33 //MA1:=MA(MX,P1); 34 MA1 := MA(MX, P1) 35 //MA2:=MA(MX,P2); 36 MA2 := MA(MX, P2) 37 //MA3:=MA(MX,P3); 38 MA3 := MA(MX, P3) 39 //DM0:MA0-MA3; 40 DM0 := MA0.Sub(MA3) 41 //DM1:MA1-MA3; 42 DM1 := MA1.Sub(MA3) 43 //DM2:MA2-MA3; 44 DM2 := MA2.Sub(MA3) 45 //X0:=DM0-REF(DM0,1); 46 X0 := DM0.Sub(REF(DM0, 1)) 47 //X1:=DM1-REF(DM1,1); 48 X1 := DM1.Sub(REF(DM1, 1)) 49 //X2:=DM2-REF(DM2,1); 50 X2 := DM2.Sub(REF(DM2, 1)) 51 //DIVERGING:X0+X1+X2; 52 DIVERGING := X0.Add(X1).Add(X2) 53 //B:X0>0 AND X1>0 AND X2>0,NODRAW; 54 B := X0.Gt(0).And(X1.Gt(0)).And(X2.Gt(0)) 55 //DRAWICON(B,0.01,1); 56 madx := JuXianDongXiang{ 57 Dm0: utils.SeriesIndexOf(DM0, -1), 58 Dm1: utils.SeriesIndexOf(DM1, -1), 59 Dm2: utils.SeriesIndexOf(DM2, -1), 60 Diverging: utils.SeriesIndexOf(DIVERGING, -1), 61 B: utils.BoolIndexOf(B, -1), 62 } 63 return &madx 64 }