3、加仓条件:当止损位移至保本价位后,若价格在均线ma2上(下)并且满足条件1时,加仓一手,
这里的条件1指的是什么?
variable:bj=0;
if all(macd>0,4) and all(macd>ref(macd,1),4) then begin
sellshort(1,0,marketr);
buy(holding=0,1,marketr);
bj:=0
end
if all(macd<0,4) and all(macd<ref(macd,1),4) then begin
sell(1,0,marketr);
buyshort(holding=0,1,marketr);
bj:=0;
end
nn1:=sumbars(cross(macd,0),1);
nn2:=sumbars(cross(0,macd),1);
QD:valuewhen(holding>0,ref(ref(llv(l,nn2),nn1),enterbars));//初始止损位
QG:valuewhen(holding<0,ref(ref(hhv(h,nn1),nn2),enterbars));//初始止损位
if c<qd and holding>0 then sell(1,0,marketr);
if c>qg and holding<0 then sellshort(1,0,marketr);
if holding>0 and hhv(h,enterbars+1)>enterprice+20*mindiff and c<enterprice then begin
sell(1,0,marketr);
bj:=1;
end
if holding<0 and llv(l,enterbars+1)<enterprice-20*mindiff and c>enterprice then begin
sellshort(1,0,marketr);
bj:=-1;
end
if bj=1 and c>ma2 and all(macd>0,4) and all(macd>ref(macd,1),4) then buy(1,1,marketr);
if bj=-1 and c<ma2 and all(macd<0,4) and all(macd<ref(macd,1),4) then buyshort(1,1,marketr);
if bj=1 and cross(ma1,ma2) then sell(1,0,marketr);
if bj=-1 and cross(ma2,ma1) then sellshort(1,0,marketr);
if all(macd>0,4) and all(macd>ref(macd,1),4) then begin
sellshort(1,0,marketr);
buy(holding=0,1,marketr);
bj:=0
end
if all(macd<0,4) and all(macd<ref(macd,1),4) then begin
sell(1,0,marketr);
buyshort(holding=0,1,marketr);
bj:=0;
end
nn1:=sumbars(cross(macd,0),1);
nn2:=sumbars(cross(0,macd),1);
QD:valuewhen(holding>0,ref(ref(llv(l,nn2),nn1),enterbars));//初始止损位
QG:valuewhen(holding<0,ref(ref(hhv(h,nn1),nn2),enterbars));//初始止损位
if c<qd and holding>0 and hhv(h,enterbars+1)<enterprice+20*mindiff then sell(1,0,marketr);
if c>qg and holding<0 and llv(l,enterbars+1)>enterprice-20*mindiff then sellshort(1,0,marketr);
if hhv(h,enterbars+1)>enterprice+20*mindiff and holding>0 and cross(ma1,ma2) then sell(1,0,marketr);
if llv(l,enterbars+1)<enterprice-20*mindiff and holding<0 and cross(ma2,ma1) then sellshort(1,0,marketr);