以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  求助多策略合并问题  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=162460)

--  作者:xia_rp
--  发布时间:2018/4/2 11:04:00
--  求助多策略合并问题
求助多策略合并问题
如秘籍中的

input:cang1(1,0,10,1),cang2(1,0,10,1);
variable:cc1=0,cc2=0;

/////////////////////////////////模型1——10周期反手
hi:=ref(hhv(h,10),1);
lo:=ref(llv(l,10),1);
if cc1>0 and l<lo then begin
 pc:=min(max(holding,0),cang1);
 kc:=cang1-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc1:=0;
end
if cc1<0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang1);
 kc:=cang1-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc1:=0;
end
if cc1=0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang1);
 kc:=cang1-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc1:=1;
end
if cc1=0 and l<lo then begin
 pc:=min(max(holding,0),cang1);
 kc:=cang1-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc1:=-1;
end

如果出场条件是多种,我们就按2种出场设置的话要如何编写? 求指教


--  作者:FireScript
--  发布时间:2018/4/2 11:19:56
--  
 需要改的是开仓条件。

比如是满足A或者满足B就开仓

开仓条件:a or b;

这样就行了。多种条件就把多个条件用or连接起来就可以了。

--  作者:xia_rp
--  发布时间:2018/4/2 11:55:06
--  
是当CC1=1或CC1=-1的开仓条件吗。如果有持仓的时候多种出场条件 他们的开平应该也都要放OR的吧
--  作者:FireScript
--  发布时间:2018/4/2 14:20:18
--  
如果出场是多种条件触发,那就用or连接多个平仓条件就可以了。  

--  作者:xia_rp
--  发布时间:2018/4/2 15:35:08
--  
好的,谢谢
--  作者:xia_rp
--  发布时间:2018/4/2 15:46:25
--  
再请教下,如果2个出场条件都是限价出场的那这个要怎么去编写啊  用了OR的话  出场价是不同的呀
--  作者:FireScript
--  发布时间:2018/4/2 16:08:21
--  
 if a or b then
begin
price:if(a,priceA,priceB)
sell(holding>0,holding,limit,price);
end

有个问题 同时触发了价格怎么选择?