macd背离指标 为何主图中 这个线条重叠了?
主题如上,为何水平线之前的垂线,有两条呢,请老师帮忙看一下哦。具体代码如下,谢谢。 另整体代码哪些地方可优化吗,烦请老师顺带指导。谢了哦 Params Numeric n1(10); Numeric n2(20); Vars Bool golden(False); Bool ending(False); Series<Numeric> ma1; Series<Numeric> ma2; Series<Numeric> new_hhh; Series<Numeric> new_lll; Series<Numeric> tem_set_h; Series<Numeric> tem_set_l; Series<Numeric> macd_yellow; Series<Numeric> new_H_l; Series<Numeric> new_L_l; Series<Numeric> macd_H_l; Series<Numeric> macd_L_l; Series<Numeric> macd_h; Series<Numeric> macd_l; Series<Numeric> tem_macd_h; Series<Numeric> tem_macd_l; Events OnBar(ArrayRef<Integer> indexs) { ma1=XAverage(c,n1); ma2=XAverage(c,n2); macd_yellow=ma1-ma2; golden=CrossOver(ma1,ma2); ending=CrossUnder(ma1,ma2); PlotNumeric("ma1",ma1); PlotNumeric("ma2",ma2); //PlotNumeric("macd_yellow",macd_yellow); tem_set_l=Lowest(l[1],NthCon(ending,0)); tem_set_h=highest(h[1],NthCon(golden,0)); //Commentary("jin="+text(NthCon(ending,0))); //Commentary("si="+text(NthCon(golden,0))); tem_set_h=highest(h[1],NthCon(golden,0)); tem_macd_h=highest(macd_yellow,NthCon(golden,0)); tem_set_l=lowest(l[1],NthCon(ending,0)); tem_macd_l=lowest(macd_yellow,NthCon(ending,0)); If(golden==true) { new_lll=tem_set_l; macd_l=tem_macd_l; } else If(ending==true) { new_hhh=tem_set_h; macd_h=tem_macd_h; } ///////////// If(new_hhh<>new_hhh[1]); { new_H_l=new_hhh[1]; macd_H_l=macd_h[1]; } If(new_lll<>new_lll[1]); { new_L_l=new_lll[1]; macd_L_l=macd_l[1]; } If(new_hhh!=0) { plotnumeric("new_hhh",new_hhh); plotnumeric("new_H_l",new_H_l); } If(new_lll!=0) { plotnumeric("new_lll",new_lll); plotnumeric("new_L_l",new_L_l); } Commentary("当前macd="+text(macd_l)); Commentary("当前macd=ll"+text(macd_L_l)); //If(my_exitprice!=0) //Commentary(text(NthCon(ending,0))); If(new_hhh>new_H_l And macd_h<macd_H_l And ending==true) { PlotString("di","顶背离",c,Yellow); } If(new_lll<new_L_l And macd_l>macd_L_l And golden==true) { PlotString("di2","底背离",c,Red); } }