日线均线金叉闪烁问题

使用日线MA金叉判断大趋势,决定当天是否做多做空,交叉信号闪烁导致K线图上有信号,实际并没有买。 Numeric FastLength(18);// 短期指数平均线参数 Numeric SlowLength(1);// 长期指数平均线参数 Numeric Day1Length(1);// 1日指数平均线参数 Numeric Day2Length(2);// 2日指数平均线参数 Series<Numeric> AvgValue1; Series<Numeric> AvgValue2; Series<Numeric> AvgDayValue1; Series<Numeric> AvgDayValue2; Global Numeric LastStepLots; Global Numeric nowCurrentBar; Bool crossOverBol; Bool crossUnderBol; Global Bool crossOverDay(False); Global Bool crossUnderDay(False); Bool crossBol; Events OnInit() { LastStepLots = 3; } OnBar(ArrayRef<Integer> indexs) { AvgValue1 = AverageFC(Close,FastLength); // 获取近3个周期收盘价平均值 AvgValue2 = AverageFC(Close,SlowLength); // 获取近8个周期收盘价平均值 AvgDayValue1 = Data1.AverageFC(Data1.Close,Day1Length);// 获取1日线平均值 AvgDayValue2 = Data1.AverageFC(Data1.Close,Day2Length);// 获取2日线平均值 // 进场 crossOverBol = CrossOver(AvgValue1[1],AvgValue2[1]); crossUnderBol = CrossUnder(AvgValue1[1],AvgValue2[1]); If(!crossOverDay){ crossBol = CrossOver(AvgDayValue1[1],AvgDayValue2[1]); If(crossBol){ If((crossUnderDay Or crossOverDay) And BarStatus==2){ crossUnderDay = False; crossOverDay = False; }Else{ If(Data1.CurrentBar - nowCurrentBar == 1){ crossUnderDay = False; crossOverDay = False; }Else{ crossUnderDay = False; crossOverDay = True; } nowCurrentBar = Data1.CurrentBar; } } } If(!crossUnderDay){ crossBol = CrossUnder(AvgDayValue1[1],AvgDayValue2[1]); If(crossBol){ If((crossUnderDay Or crossOverDay) And BarStatus==2){ crossUnderDay = False; crossOverDay = False; }Else{ If(Data1.CurrentBar - nowCurrentBar == 1){ crossUnderDay = False; crossOverDay = False; }Else{ crossUnderDay = True; crossOverDay = False; } nowCurrentBar = Data1.CurrentBar; } } } // 做多 If(MarketPosition==0 And Lots != 0 And crossOverDay And crossOverBol){ Buy(LastStepLots,Open); PlotString("多信号","做多"+Text(LastStepLots)+"手",Close,White); } // 做空 If(MarketPosition==0 And Lots != 0 And crossUnderDay And crossUnderBol){ SellShort(LastStepLots,Open); PlotString("空信号","做空"+Text(LastStepLots)+"手",Close,White); } } 想问下老师应该要怎么改才能避免日线金叉闪烁问题,另外应该怎么计算日线发生金叉时的具体价格是多少。

插入同一商品两个,周期设置不同

你这个有多图层? 图层是怎么叠加的