以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  策略编写求助区  (http://weistock.com/bbs/list.asp?boardid=11)
----  平仓编写  (http://weistock.com/bbs/dispbbs.asp?boardid=11&id=10577)

--  作者:pearlhu
--  发布时间:2012/3/15 9:54:28
--  平仓编写
我想请教一下 我手里有一手仓位的时候高点回撤10个点平仓,手里有两手仓位的时候高点回落10个点平一手,回落20个点再平第二手,怎么写

--  作者:jinzhe
--  发布时间:2012/3/15 10:10:30
--  

variable:aa=0;

 

 

if c>aa then aa:=c;

 

if aa>0 and c<=aa-10*mindiff  and holding=1 then sell(holding>0,1,thisclose);

 

if aa>0 and c<=aa-20*mindiff and holding=2 then sell(holding>0,2,thisclose);


--  作者:pearlhu
--  发布时间:2012/3/15 10:55:06
--  
如果是有两手仓位,是要分开平的
--  作者:pearlhu
--  发布时间:2012/3/15 10:56:30
--  

if holding=2 then begin
 
 sell(l<=h135-10,1,LIMITR,h135-10);
 
 sell(l<=h135-20,1,LIMITR,h135-20);
 
 end

这样 表达对么


--  作者:jinzhe
--  发布时间:2012/3/15 11:02:48
--  

variable:aa=0,bb=0;

 

 加个开仓语句保证全局变量不出错

if buycond then begin

buy();

aa:=0;

bb:=0;

end

 

if c>aa then aa:=c;

 

if aa>0 and c<=aa-10*mindiff  and  holding=1 then sell(holding>0,1,thisclose);

 

if aa>0 and c<=aa-10*mindif and holding=2 and bb=0 then begin

sell(holding>0,1,thisclose);

bb:=1;

end

if aa>0 and c<=aa-20*mindiff  and bb=1 then sell(holding>0,1,thisclose);

[此贴子已经被作者于2012-3-15 11:03:05编辑过]