{均线战法}
INPUT:N1(8,0.01,100,0.05);
VARIABLE:MAXPROFIT=0,{有仓位时最大获利幅度}VMIN = 090000;{用于隔夜高开或低开时间差}
ma1:ma(c,n1);
runmode:0;
YdZyD:=1,linethick0; {移动止盈总开关,1为开,0为关}
variable:baramount=0;
variable:barvol=0;
if barpos<=1 then exit;
if date<>date[barpos-1] then begin
baramount:=amount;
barvol:=vol;
end else begin
baramount:=baramount[barpos-1]+amount;
barvol:=barvol[barpos-1]+vol;
end
averageprice:=baramount/barvol/multiplier;
均价线:round(averageprice/mindiff)*mindiff,linethick2,coloryellow;
a:=open+3*mindiff;
b:=open-3*mindiff;
//建立多头的进场条件
long:=cross(ma1,averageprice);
if long then
begin
sellshort(holding<0,1,MKT),orderqueue;
buy(holding=0,1,limitr,a),orderqueue,;
end
//建立空头的进场条件
short:=cross(averageprice,ma1);
if short then
begin
sell(holding>0,1,MKT),orderqueue;
buyshort(holding=0,1,limitr,b),orderqueue;
end
//多移动止盈
If YdZyD=1 and Enterbars>=0 then begin
//a.每周期判断是否创新低
if holding > 0 and enterbars > 0 then
begin
win:=(c-enterprice)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
end
//b.当开仓后,盈利达到80到380点时,回撤80%,平仓
if c-enterprice>80*mindiff and c-enterprice<380*mindiff and holding>0 then
begin
SELL(win2 >= 20, 1,market);
end
//空移动止盈A
If YdZyD=1 and Enterbars>=0 then begin
//a.每周期判断是否创新低
if holding > 0 and enterbars > 0 then
begin
win:=(c-enterprice)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
end
//b.当开仓后,盈利达到80到380点时,回撤80%,平仓
if c-enterprice>80*mindiff and c-enterprice<380*mindiff and holding>0 then
begin
SELL(win2 >= 20, 1,market);
end
盈亏:asset,noaxis,colorgray;
收益:(asset-50000)/50000,linethick0;
次数:totaltrade,linethick0;
胜率:percentwin,linethick0;
连亏:maxseqloss,linethick0;
连赢:maxseqwin,linethick0;
其实每次都有机会正收益,但实际运行不理想,保不住收益