等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
|
if holding=0 then
begin
if 开多平空条件 and (多空开关=1 or 多空开关=2) then
begin
firstvol:=intpart(if(起始数额<=2000,起始数额,起始数额/(max(highestaftercross,o)*保证金比例*MULTIPLIER)));
if firstvol>=1 and date<=结束日期 and 交易次数<最大交易次数 then
begin
//图表交易,后台交易用来区分各策略的持仓
price1:=max(highestaftercross,o)+hd*mindiff;//图表显示及回测
buy(1,firstvol,limitr,price1),ignorecheckprice;
//后台交易
tbuy(1,firstvol,lmt,min(dynainfo2(54,kcname),dynainfo2(28,kcname)+hd*mindiff),0,'',kcname),ignorecheckprice;
end
end
if 开空平多条件 and (多空开关=-1 or 多空开关=2) then
begin
firstvol:=intpart(if(起始数额<=2000,起始数额,起始数额/(min(lowestaftercross,o)*保证金比例*MULTIPLIER)));
if firstvol>=1 and date<=结束日期 and 交易次数<最大交易次数 then
begin
//图表交易,后台交易用来区分各策略的持仓
price1:=min(lowestaftercross,o)-hd*mindiff;//图表显示及回测
buyshort(1,firstvol,limitr,price1),ignorecheckprice;
//后台交易
tbuyshort(1,firstvol,lmt,max(dynainfo2(55,kcname),dynainfo2(34,kcname)-hd*mindiff),0,'',kcname),ignorecheckprice;
end
end
end
else
begin
if 开多平空条件 and holding<-0.5 then
begin
//图表交易,后台交易用来区分各策略的持仓
firstvol:=intpart(if(起始数额<=2000,起始数额,起始数额/(max(highestaftercross,o)*保证金比例*MULTIPLIER)));
price0:=max(highestaftercross,o)+hd*mindiff;//图表显示及回测
sellshort(1,firstvol,limitr,price0),ignorecheckprice;
price1:=max(highestaftercross,o)+hd*mindiff;//图表显示及回测
if (多空开关=1 or 多空开关=2) then buy(1,firstvol,limitr,price1),ignorecheckprice;
//后台交易
tsellshort(1,firstvol,lmt,min(dynainfo2(54,pcname),dynainfo2(28,pcname)+hd*mindiff),0,'',pcname),ignorecheckprice;
交易次数:=交易次数+1;
if NUMPROFIT(1)>0 then 亏损次数:=0; else 亏损次数:=亏损次数+1;
if 1 then
begin
if (多空开关=1 or 多空开关=2) then tbuy(1,firstvol,lmt,min(dynainfo2(54,kcname),dynainfo2(28,kcname)+hd*mindiff),0,'',kcname),ignorecheckprice;
end
end
if 开空平多条件 and holding>0.5 then
begin
//图表交易,后台交易用来区分各策略的持仓
firstvol:=intpart(if(起始数额<=2000,起始数额,起始数额/(max(highestaftercross,o)*保证金比例*MULTIPLIER)));
price0:=min(lowestaftercross,o)-hd*mindiff;//图表显示及回测
sell(1,firstvol,limitr,price0),ignorecheckprice;
price1:=min(lowestaftercross,o)-hd*mindiff;//图表显示及回测
if (多空开关=-1 or 多空开关=2) then buyshort(1,firstvol,limitr,price1),ignorecheckprice;
//后台交易
tsell(1,firstvol,lmt,max(dynainfo2(55,pcname),dynainfo2(34,pcname)-hd*mindiff),0,'',pcname),ignorecheckprice;
交易次数:=交易次数+1;
if NUMPROFIT(1)>0 then 亏损次数:=0; else 亏损次数:=亏损次数+1;
if 1 then
begin
if (多空开关=1 or 多空开关=2) then tbuyshort(1,firstvol,lmt,max(dynainfo2(55,kcname),dynainfo2(34,kcname)-hd*mindiff),0,'',kcname),ignorecheckprice;
end
end
end |
|