globalvariable:n=1000000;
GLOBALVARIABLE:dd=0;
GLOBALVARIABLE:f=1;
GLOBALVARIABLE:a=0;
jia:=20;
hui:=10;
da:=5;
追踪止盈点数:=10;
if TREMAINQTY(0,'','')>0 and tenterbars(1)>1 then begin
TCANCEL(1,0);
END
if TBUYHOLDINGEX('','',1)>0 and TBUYHOLDINGEX('','',1)<da AND TENTERPRICE>0 then
BEGIN
if f=3 AND TENTERPRICE>0 then
begin
if c<=Tenterprice+5*mindiff and c>=Tenterprice-5*mindiff then begin
TBUY(1,1,MKT);
f:=2;
if islastbar then
DEBUGFILE('D:\35.TXT',' Tenterprice:%.2f',Tenterprice);//输出开仓价格
end
if c<=Tenterprice-(jia+hui)*mindiff THEN begin
TSELL(1,0,MKT);
f:=1;
end
if c>=Tenterprice+(hui+jia)*mindiff then begin
TBUY(1,1,MKT);
f:=1;
if islastbar then
DEBUGFILE('D:\35.TXT',' Tenterprice:%.2f',Tenterprice);//输出开仓价格
end
end
if f=2 AND TENTERPRICE>0 then
BEGIN
if c>=Tenterprice+hui*mindiff then begin
TSELL(1,1,MKT);
f:=3;
end
if c<=Tenterprice-(jia+hui)*mindiff THEN begin
TSELL(1,0,MKT);
f:=1;
end
if c>=Tenterprice+(hui+jia)*mindiff then begin
TBUY(1,1,MKT);
f:=1;
if islastbar then
DEBUGFILE('D:\35.TXT',' Tenterprice:%.2f',Tenterprice);//输出开仓价格
end
end
if f=1 AND TENTERPRICE>0 then
BEGIN
if c<=Tenterprice-jia*2*mindiff THEN begin
TSELL(1,0,MKT);
f:=1;
end
if c>=Tenterprice+jia*mindiff then begin
TBUY(1,1,MKT);
f:=1;
if islastbar then
DEBUGFILE('D:\35.TXT',' Tenterprice:%.2f',Tenterprice);//输出开仓价格
end
if c<=Tenterprice-hui*mindiff then BEGIN
TBUY(1,1,MKT);
f:=2;
if islastbar then
DEBUGFILE('D:\35.TXT',' Tenterprice:%.2f',Tenterprice);//输出开仓价格
end
end
end
if TBUYHOLDINGEX('','',1)=da THEN BEGIN
if f=3 AND TENTERPRICE>0 then
begin
if c<=Tenterprice+5*mindiff and c>=Tenterprice-5*mindiff then begin
TBUY(1,1,MKT);
f:=2;
if islastbar then
DEBUGFILE('D:\35.TXT',' Tenterprice:%.2f',Tenterprice);//输出开仓价格
end
if c<=Tenterprice-(jia+hui)*mindiff THEN begin
TSELL(1,0,MKT);
f:=1;
end
if c>=Tenterprice+(hui+jia)*mindiff then begin
TBUY(1,1,MKT);
f:=1;
if islastbar then
DEBUGFILE('D:\35.TXT',' Tenterprice:%.2f',Tenterprice);//输出开仓价格
end
end
if f=2 AND TENTERPRICE>0 then BEGIN
if c>=Tenterprice+hui*mindiff then begin
TSELL(1,1,MKT);
f:=3;
end
if c<=Tenterprice-(jia+hui)*mindiff THEN begin
TSELL(1,0,MKT);
f:=1;
end
END
if f=1 AND TENTERPRICE>0 then begin
if a=0 then
a:=Tenterprice;
if a>0 THEN BEGIN
if c-追踪止盈点数*mindiff >a THEN
a:=c-追踪止盈点数*mindiff;
if c<=a then
begin
TSELL(1,0,MKT);
f:=1;
end
END
end
end
if TBUYHOLDINGEX('','',1)=0 AND TREMAINQTY(0,'','')=0 THEN begin
TBUY(1,1,MKT);
if islastbar then
DEBUGFILE('D:\35.TXT',' Tenterprice:%.2f',Tenterprice);//输出开仓价格
END