-- jinzhe 老师 帮我再修改一个小问题
dd:=if(date>1130301,1,1);
trr:=max(max((high-low),abs((ref(close,1)-high))),abs((ref(close,1)-low)))*dd;
hh:=c+trr*dd*倍数/10,colorgray;
ll:=c-trr*dd*倍数/10,colorgray;
llxx:=ref(hhv(ll,5),1)*dd;
hlxx:=ref(llv(hh,5),1)*dd;
chxx:=cross(c,hlxx*1.000001);
clxx:=(0-cross(llxx*0.999999,c));
tfxx:=if(chxx,chxx,if(cross(llxx*0.999999,c),clxx,0));
udxx:=ref(tfxx,barslast(tfxx));
llxxx:=hhv(ll,barslast(udxx<0));
hlxxx:=llv(hh,barslast(udxx>0));
chxxx:=cross(c,hlxxx*1.000001);
clxxx:=(0-cross(llxxx*0.999999,c));
tfxxx:=if(chxxx,chxxx,if(cross(llxxx*0.999999,c),clxxx,0));
udxxx:=ref(tfxxx,barslast(tfxxx));
llxxxx:=min(hhv(ll,barslast(udxxx<0)),llxxx);
hlxxxx:=max(llv(hh,barslast(udxxx>0)),hlxxx);
chxxxx:=cross(c,hlxxxx*1.000001);
clxxxx:=(0-cross(llxxxx*0.999999,c));
tfxxxx:=if(chxxxx,chxxxx,if(cross(llxxxx*0.999999,c),clxxxx,0));
udxxxx:=ref(tfxxxx,barslast(tfxxxx));
llxxxxx:=min(hhv(ll,barslast(udxxxx<0)),llxxxx);
hlxxxxx:=max(llv(hh,barslast(udxxxx>0)),hlxxxx);
chxxxxx:=cross(c,hlxxxxx*1.000001);
clxxxxx:=(0-cross(llxxxxx*0.999999,c));
tfxxxxx:=if(chxxxxx,chxxxxx,if(cross(llxxxxx*0.999999,c),clxxxxx,0));
udxxxxx:=ref(tfxxxxx,barslast(tfxxxxx));
llxxxxxx:=min(hhv(ll,barslast(udxxxxx<0)),llxxxxx);
hlxxxxxx:=max(llv(hh,barslast(udxxxxx>0)),hlxxxxx);
bbx:=llxxxxxx*0.999999;
ssx:=hlxxxxxx*1.000001;
b1x:=if(cross(c,ssx),1,if(cross(bbx,c),-1,0))*dd;
b2x:=ref(b1x,barslast(b1x))*dd;
w:=if(b2x=1,bbx,if(b2x=-1,ssx,c))*dd,coloryellow;
bbx:=ema(llv(l,3),5)*0.999999*dd;
ssx:=ema(hhv(h,3),5)*1.000001*dd;
b1x:=if(cross(c,ssx),1,if(cross(bbx,c),-1,0));
b2x:=ref(b1x,barslast(b1x));
多空转折线:=if(b2x=1,bbx,if(b2x=-1,ssx,0))*dd;
w,coloryellow,linethick2;
ll:=bbx;
hl:=ssx;
ch:=cross(c,hl);
cl:=(0-cross(ll,c));
tf:=if(ch,ch,if(cross(ll,c),cl,0));
ud:=ref(tf,barslast(tf));
lll:=ema(llv(l,3),5)*dd;
hhh:=ema(hhv(h,3),5)*dd;
kkk:=(barslast(cross(ref(llv(l,25),1)*0.99999,llv(c,25)))-barslast(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001)))*dd,nodraw;
stickline(kkk>0,o,c,6,0),colorred;
stickline(kkk>0,h,l,0,0),colorred;
stickline(kkk>0 and c>o,o,c,6,1),colorred;
stickline(kkk<0,o,c,6,0),color00aa00;
stickline(kkk<0,h,l,0,0),color00aa00;
stickline(kkk<0 and c>o,o,c,6,1),color00aa00;
partline(c>w and not(cross(c,w)),w),colormagenta,linethick2;
partline(c<w and not(cross(w,c)),w),colorcyan,linethick2;
drawtext(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001),bbx*0.9995,\'开多\'),colorred;
drawtext(cross(ref(llv(l,25),1)*0.99999,llv(c,25)),ssx*1.0005,\'开空\'),colorgreen;
kd:barslast(((cross(w,c) and c>多空转折线) or (cross(多空转折线,c) and c>w) or (cross(多空转折线,c) and cross(w,c))) and kkk>0)-barslast(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001)),nodraw;
kk:barslast(((cross(c,w) and c<多空转折线) or (cross(c,多空转折线) and c<w) or (cross(c,多空转折线) and cross(c,w))) and kkk<0)-barslast(cross(ref(llv(l,25),1)*0.99999,llv(c,25))),nodraw;
drawtext(cross(0,kd) and kkk>0,w,\'平多\'),coloryellow;
drawtext(cross(0,kk) and kkk<0,w,\'平空\'),coloryellow;
kdss:=5;//开多手数
jdss:=2;//加多手数
kkss:=5;//开空手数
jkss:=2;//加空手数
if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001) and holding=0 then begin
buy(holding=0,kdss,thisclose);
end
if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001) and holding>0 and enterbars>0 then begin
buy(holding>0,jdss,market);
end
if cross(ref(llv(l,25),1)*0.99999,llv(c,25)) and holding=0 then begin
buyshort(holding=0,kkss,thisclose);
end
if cross(ref(llv(l,25),1)*0.99999,llv(c,25)) and holding<0 and enterbars>0 then begin
buyshort(holding<0,jkss,market);
end
if cross(0,kd) and kkk>0 then sell(1,0,market);
if cross(0,kk) and kkk<0 then sellshort(1,0,market);
还是上次的指标,感谢您的修改。目前发现一个问题。就是如果指标出现了:“开多” 而第二根线没有出现“平多” 而是直接“开空”了 , 目前指标没有平多开空。 我想让它能在信号发生变化时,即使不出现平多,平空 也要反手。比如开空后 接着出现开多 那么就反手多,相反 开空后 如果开多 那就反手多