以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]请教老师,请问如何才能增加1%2%3%的分步骤止盈呢?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=72089)

--  作者:zhoutuoying
--  发布时间:2014/11/17 21:35:37
--  [求助]请教老师,请问如何才能增加1%2%3%的分步骤止盈呢?
5h:=STKINDIEX(\'\',\'5H5L.5H\',0,6,0,100);//调用;
5l:=STKINDIEX(\'\',\'5H5L.5L\',0,6,0,100);//调用;

//=============;
ss:=zsje/MULTIPLIER/0.01/open;
//=============;
SELLSHORT(high>5H AND HOLDING<0,TSELLHOLDING(1),marketr);//平空
SELLSHORT(OPENPROFIT<-zsje AND HOLDING<0,TSELLHOLDING(1),marketr);//平空止损

BUY(high>5h AND HOLDING<=0,SS,marketr);          //开多信号

SELL(low<5l AND HOLDING>0,TBUYHOLDING(1),marketr); //平多
SELL(OPENPROFIT<-zsje AND HOLDING>0,TBUYHOLDING(1),marketr);//平多止损

BUYSHORT(low<5l AND HOLDING>=0,SS,marketr);     //开空信号

当前持仓:HOLDING,COLORGRAY,LINETHICK0;
当前资产:ASSET,NOAXIS,COLORGRAY;

--  作者:jinzhe
--  发布时间:2014/11/18 9:14:21
--  

variable:n=0;

if n=0 and holding=整体手数 and (h-enterprice)/enterprice>0.01 then begin

     sell(1,这里写1%止赢的手数,market);

     n:=1;

end

 

if n=1 and holding=1%止赢后的手数 and (h-enterprice)/enterprice>0.02 then begin

     sell(1,这里写2%止赢的手数,market);

     n:=2;

end

 

if n=2 and holding=前面两个止盈后的手数 and (h-enterprice)/enterprice>0.03 then begin

     sell(1,0,market);//3%剩下的就全平拉

     n:=0;

end

variable:m=0;

if m=0 and holding=整体手数 and (enterprice-l)/l>0.01 then begin

     sellshort(1,这里写1%止赢的手数,market);

     m:=1;

end

 

if m=1 and holding=1%止赢后的手数 and (enterprice-l)/l>0.02 then begin

     sellshort(1,这里写2%止赢的手数,market);

     m:=2;

end

 

if m=2 and holding=前面两个止盈后的手数 and (enterprice-l)/l>0.03 then begin

     sellshort(1,0,market);//3%剩下的就全平拉

     m:=0;

end

 


--  作者:zhoutuoying
--  发布时间:2014/11/18 10:21:58
--  
谢谢老师!
--  作者:zhoutuoying
--  发布时间:2014/11/18 16:39:31
--  
能否麻烦老师帮忙把减仓策略增加进开仓策略中呢?谢谢
1%平原有仓位的三分一
2%平原有仓位的三分一
3%全平


自己组合起来问题多多

--  作者:zhoutuoying
--  发布时间:2014/11/18 16:40:50
--  
且3%全平后若未符合反手条件不开仓
--  作者:zhoutuoying
--  发布时间:2014/11/18 16:41:45
--  
我是新手,还望老师指导
--  作者:jinzhe
--  发布时间:2014/11/18 16:44:17
--  

variable:n=0;

那么在这里假定你的开多手数为m,开空手数为k

if n=0 and holding=m and (h-enterprice)/enterprice>0.01 then begin

     sell(1,m/3,market);

     n:=1;

end

 

if n=1 and holding=m*2/3 and (h-enterprice)/enterprice>0.02 then begin

     sell(1,m/3,market);

     n:=2;

end

 

if n=2 and holding=m/3 and (h-enterprice)/enterprice>0.03 then begin

     sell(1,0,market);//3%剩下的就全平拉

     n:=0;

end

variable:m=0;

if m=0 and holding=k and (enterprice-l)/l>0.01 then begin

     sellshort(1,k/3,market);

     m:=1;

end

 

if m=1 and holding=k*2/3 and (enterprice-l)/l>0.02 then begin

     sellshort(1,k/3,market);

     m:=2;

end

 

if m=2 and holding=k/3 and (enterprice-l)/l>0.03 then begin

     sellshort(1,0,market);//3%剩下的就全平拉

     m:=0;

end