以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请版主帮忙修改........  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=76961)

--  作者:jckk
--  发布时间:2015/3/26 15:56:14
--  请版主帮忙修改........

variable:hl=0,zs=0;

HiBand1:=ref(hhv(h,B_Length1),1);
LoBand2:=llv(l,B_Length2);
LoBand1:=ref(llv(l,S_Length1),1);
HiBand2:=hhv(h,S_Length2);
B_atr:=B_TrailStopNumATR*ma(tr,B_ATRLength);
S_atr:=S_TrailStopNumATR*ma(tr,S_ATRLength);
if islastbar and dynainfo(207)<opentime(1) then exit;//过滤集合竞价
if holding>0 and l<zs then begin
 sell(1,1,limitr,min(o,zs));
 
end
if holding<0 and h>zs then begin
 sellshort(1,1,limitr,max(o,zs));

end
if holding=0 and h>HiBand1 and time>103000 then begin
 buy(1,1,limitr,max(o,HiBand1));
 hl:=h;
end
if holding=0 and l<LoBand1 and time>103000 then begin
 buyshort(1,1,limitr,min(o,LoBand1));
 hl:=l;
end
skip@;
if holding>0 and h>=hl then begin
 hl:=h;
 zs:=max(hl-B_TrailStopNumATR*B_atr,LoBand2);
end
if holding<0 and l<=hl then begin
 hl:=l;
 zs:=min(hl+S_TrailStopNumATR*S_atr,HiBand2);
end
资产:asset,noaxis,colorred,linethick2;

 

 

 

 

一,请版主修改持仓 大于等于1就不再加仓,

二,当有持有仓位时反向开仓时先平仓再开仓

 

     谢谢!!!!


--  作者:jinzhe
--  发布时间:2015/3/26 16:02:05
--  
if holding>0 and l<zs then begin
 sell(1,1,limitr,min(o,zs));
 
end
if holding<0 and h>zs then begin
 sellshort(1,1,limitr,max(o,zs));

end
if h>HiBand1 and time>103000 and holding<0 then begin

 sellshort(holding<0,1,market);
 buy(holding=0,1,limitr,max(o,HiBand1));
 hl:=h;
end
if holding>0 and l<LoBand1 and time>103000 then begin

 sell(holding>0,1,market);
 buyshort(holding=0,1,limitr,min(o,LoBand1));
 hl:=l;
end
skip@;
if holding>0 and h>=hl then begin
 hl:=h;
 zs:=max(hl-B_TrailStopNumATR*B_atr,LoBand2);
end
if holding<0 and l<=hl then begin
 hl:=l;
 zs:=min(hl+S_TrailStopNumATR*S_atr,HiBand2);
end