顶背离

如果macd发生顶背离本次死叉不进行后续操作或者在下次死叉前不尽兴后续操作。有没有大神帮一下啊,想不出来怎么写

Params Numeric FastLength(12); Numeric SlowLength(26); Numeric MACDLength(9);Vars Series<Numeric> fast; Series<Numeric> slow; //这3个是 Series<Numeric> MACDValue; Series<bool> con1; Series<bool> con2; Natural bool con_dbl_ding; Natural bool con_dbl_di; Natural bool con_buy; Natural bool con_sicha; Natural bool con_jincha; Series<Numeric> macd_low; Series<Numeric> macd_high; Series<Numeric> highx; Series<Numeric> lowx; Series<Numeric> my_macd_high; Series<Numeric> my_macd_highx; Series<Numeric> my_high; Series<Numeric> my_highx; Series<Numeric> my_macd_low; Series<Numeric> my_macd_lowx; Series<Numeric> my_low; Series<Numeric> my_lowx;EventsOnBar(ArrayRef<Integer> indexs) { Range[0:DataSourceSize() - 1] { fast = XAverage( Close, FastLength ) - XAverage( Close, SlowLength ) ; slow = XAverage(fast,MACDLength); MACDValue = fast - slow; } con1 = CrossOver(fast,slow);//金叉 con2 = CrossUnder(fast,slow);//死叉 Numeric a; //Numeric macdx; Numeric b; //Numeric macdxx; a = NthCon(con2,1); b = NthCon(con1,1); highx = highest(high,b+1); lowx = Lowest(low,a+1); macd_low = Lowest(fast,a+1); macd_high = highest(fast,b+1); Commentary(\"a=\"+Text(a)); Commentary(\"macdx:\"+Text(macd_low)); Commentary(\"highx:\"+Text(highx)); Commentary(\"lowx:\"+Text(lowx)); if(con2)//求死叉下的最大值 { my_high = highx; my_highx = my_high[1]; my_macd_high = macd_high; my_macd_highx = my_macd_high[1]; } con_dbl_ding = my_high>my_highx and my_macd_high<my_macd_highx and con2;if(con_dbl_ding) PlotBool(\"11\",true);}这 con_dbl_ding 是顶背离 如何在下一次死叉前代码不进行后续运行

关键是顶背离怎么用数学去描述先把这个确定才行

回复:ParamsNumeric FastLength(12);Numeric SlowLength(26);Numeric MACDLength(9);VarsSeries<Numeric> fast;Series<Numeric> slow; //这3个是Series<Numeric> MACDValue;Series<bool> con1;Series<bool> con2; Natural bool con_dbl_ding; Natural bool con_dbl_di;Natural bool con_buy;Natural bool con_sicha; Natural bool con_jincha; Series<Numeric> macd_low;Series<Numeric> macd_high;Series<Numeric> highx;Series<Numeric> lowx;Series<Numeric> my_macd_high;Series<Numeric> my_macd_highx;Series<Numeric> my_high;Series<Numeric> my_highx;Series<Numeric> my_macd_low;Series<Numeric> my_macd_lowx;Series<Numeric> my_low;Series<Numeric> my_lowx;EventsOnBar(ArrayRef<Integer> indexs){Range[0:DataSourceSize() - 1]{fast = XAverage( Close, FastLength ) - XAverage( Close, SlowLength ) ;slow = XAverage(fast,MACDLength);MACDValue = fast - slow;}con1 = CrossOver(fast,slow);//金叉 con2 = CrossUnder(fast,slow);//死叉 Numeric a; //Numeric macdx; Numeric b; //Numeric macdxx; a = NthCon(con2,1); b = NthCon(con1,1); highx = highest(high,b+1); lowx = Lowest(low,a+1); macd_low = Lowest(fast,a+1); macd_high = highest(fast,b+1); Commentary(\"a=\"+Text(a)); Commentary(\"macdx:\"+Text(macd_low)); Commentary(\"highx:\"+Text(highx)); Commentary(\"lowx:\"+Text(lowx)); if(con2)//求死叉下的最大值 { my_high = highx; my_highx = my_high[1]; my_macd_high = macd_high; my_macd_highx = my_macd_high[1]; }con_dbl_ding = my_high>my_highx and my_macd_high<my_macd_highx and con2;if(con_dbl_ding) PlotBool(\"11\",true);}这 con_dbl_ding 是顶背离 如何在下一次死叉前代码不进行后续运行