Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共10 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:请教固定止盈止损模型写法

1楼
bizstar 发表于:2013/3/25 10:49:27

请教一下,在下面的模型中,增加固定n点止盈和固定n1点止损,该怎么添加呀。

hi:=ref(hhv(h,x),1);
lo:=ref(llv(l,x),1);
if cc2>0 and l<lo then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-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);
 cc2:=0;
end
if cc2<0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-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);
 cc2:=0;
end
if cc2=0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-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);
 cc2:=1;
end
if cc2=0 and l<lo then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-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);
 cc2:=-1;
end

2楼
just 发表于:2013/3/25 11:14:47
工作人员在处理,请稍后
3楼
bizstar 发表于:2013/3/25 11:22:01
谢谢。
4楼
just 发表于:2013/3/25 11:22:30

hi:=ref(hhv(h,x),1);
lo:=ref(llv(l,x),1);

if holding>0 and enterprice-close>n then sell(1,1,market);
if holding<0 and close-enterprice<n1 then sellshort(1,1,market);
if cc2>0 and l<lo then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-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);
 cc2:=0;
end
if cc2<0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-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);
 cc2:=0;
end
if cc2=0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-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);
 cc2:=1;
end
if cc2=0 and l<lo then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-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);
 cc2:=-1;
end

[此贴子已经被作者于2013-3-25 11:22:42编辑过]
5楼
bizstar 发表于:2013/3/25 11:33:28
我这个策略上面还有个模型1,2个要同时存在,用holding可以吗
6楼
bizstar 发表于:2013/3/25 11:33:58
而且开仓价格也不能那么写吧。
7楼
bizstar 发表于:2013/3/25 12:20:42

这么写是否可以呢?

hi:=ref(hhv(h,x),1);
lo:=ref(llv(l,x),1);

if cang2>0 and zs-close>n1 then sell(1,1,limitr,zs-n1);
if cang2>0 and close-zs>n then  sell(1,1,limitr, zs+n);
if cang2<0 and close-zs<n1 then sellshort(1,1,limitr,zs+n1);
if cang2>0 and close-zs>n then sellshort(1,1,limitr,zs-n);
 
if cc2>0 and l<lo then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-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);
zs:=c;
 cc2:=0;
end
if cc2<0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-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);
zs:=c;
 cc2:=0;
end
if cc2=0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-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);
zs:=c;
 cc2:=1;
end
if cc2=0 and l<lo then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-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);
zs:=c;
 cc2:=-1;
end
8楼
just 发表于:2013/3/25 13:34:54
由于我不清楚你某些变量的含义 故只能给你写个大概的意思 
[此贴子已经被作者于2013-3-25 13:35:08编辑过]
9楼
bizstar 发表于:2013/3/25 13:44:36
还是谢谢,已经支付悬赏。希望能和你进一步交流
10楼
qq2755580912 发表于:2014/9/2 15:14:48

怎么在模型中写入固定止损和止盈

 

共10 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.02344 s, 3 queries.