欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 请教如下程序如何做到连亏两次则开反手仓

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有2652人关注过本帖树形打印复制链接

主题:请教如下程序如何做到连亏两次则开反手仓

帅哥哟,离线,有人找我吗?
panjia1000
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:0 威望:0 精华:0 注册:2013/9/22 14:24:24
请教如下程序如何做到连亏两次则开反手仓  发帖心情 Post By:2015/6/20 16:11:01    Post IP:111.73.26.34[只看该作者]

variable:HigherAfterEntry=0,LowerAfterEntry=999999;
input:n1(1,1,3,1); 
input:n2(14,5,40,1); 
input:n3(95,50,100,1);
MA5: MA(CLOSE,5);                                                   
MA10:MA(CLOSE,10);                                                  
MA20:MA(CLOSE,20);                                                  
avvol:ma(ref(vol,2),5),noaxis,linethick0;
dayopen:=valuewhen(date<>ref(date,1),open);
if date<>ref(date,1) then
begin
loss:=0; 
count1:=1;
end
计数一:=count1,noaxis,linethick0;
计数二:=loss,noaxis,linethick0;
h_1:=ref(h,1);
l_1:=ref(l,1);
lots:=1;
 If enterbars=0 then 
begin
HigherAfterEntry:=enterprice;
LowerAfterEntry:=enterprice;
end;
else If enterbars>=1 then 
begin
HigherAfterEntry:=max(HigherAfterEntry,h_1);
LowerAfterEntry:=min(LowerAfterEntry,l_1);
end;
hh:HigherAfterEntry,noaxis,linethick0;
ll:LowerAfterEntry,noaxis,linethick0;
 if holding>0  and  l<=ENTERPRICE-n2 
 then  
 begin
 sell(1,holding,limitr,enterprice-n2),IGNORECHECKPRICE;
 end
 if holding<0  and  h>=ENTERPRICE+n2 
 then  
 begin
 sellshort(1,holding,limitr,enterprice+n2),IGNORECHECKPRICE;
 end
if  holding=0  and count1=1 then
 begin 
if  MA5>=MA10+2 then
 begin
 buy(1,lots,limitr,open),IGNORECHECKPRICE;
HigherAfterEntry:=enterprice;
LowerAfterEntry:=enterprice;
end
end
if holding=0  and count1=1 
 then 
 begin 
if  MA5<=MA10-2  then
 begin
  buySHORT(1,lots,limitr,open),IGNORECHECKPRICE;
HigherAfterEntry:=enterprice;
LowerAfterEntry:=enterprice;
end
end
if holding>0 and enterbars>0  then
 begin 
 if  enterbars>=1  and HigherAfterEntry>=enterprice*(1+N1/100)   
 then
 begin
 price:=EnterPrice+(HigherAfterEntry-EnterPrice)*n3/100;
 if low<=price then
 begin
 sell(1,holding,limitr,min(open,price)) ,IGNORECHECKPRICE;
  count1:=1;
end
end;
end;
 if holding<0 and enterbars>0  then
 begin 
 if  enterbars>=1    and lowerAfterEntry<=enterprice*(1-N1/100)
 then
 begin
 price:=EnterPrice - (EnterPrice-LowerAfterEntry)*n3/100;
 if high>=price then
 begin
 sellshort(1,holding,limitr,max(open,price)),IGNORECHECKPRICE;
  count1:=1;
end;
end
end;
 

 回到顶部
帅哥哟,离线,有人找我吗?
panjia1000
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:0 威望:0 精华:0 注册:2013/9/22 14:24:24
即多仓连亏两次就反手开空仓,或空仓连亏两次就开多仓  发帖心情 Post By:2015/6/20 16:16:07    Post IP:111.73.26.34[只看该作者]

即多仓连亏两次就反手开空仓,或空仓连亏两次就开多仓

 回到顶部
帅哥哟,离线,有人找我吗?
jinzhe
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2015/6/23 8:55:08    Post IP:58.246.57.26[只看该作者]

count1是自己的计数变量吗?


金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

 回到顶部
帅哥哟,离线,有人找我吗?
panjia1000
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:0 威望:0 精华:0 注册:2013/9/22 14:24:24
count1是自己的计数变量  发帖心情 Post By:2015/6/23 22:20:40    Post IP:182.99.87.22[只看该作者]

count1是自己的计数变量

 回到顶部
帅哥哟,离线,有人找我吗?
jinzhe
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2015/6/24 9:31:04    Post IP:58.246.57.26[只看该作者]

variable:HigherAfterEntry=0,LowerAfterEntry=999999;
variable:cs_duo=0,bj=0,cs_kong=0;
input:n1(1,1,3,1);
input:n2(14,5,40,1);
input:n3(95,50,100,1);
MA5: MA(CLOSE,5);                                                  
MA10:MA(CLOSE,10);                                                 
MA20:MA(CLOSE,20);                                                 
avvol:ma(ref(vol,2),5),noaxis,linethick0;
dayopen:=valuewhen(date<>ref(date,1),open);

h_1:=ref(h,1);
l_1:=ref(l,1);
lots:=1;

 

hh:HigherAfterEntry,noaxis,linethick0;
ll:LowerAfterEntry,noaxis,linethick0;


if  holding=0 and  MA5>=MA10+2  then
begin
  buy(1,lots,limitr,open),IGNORECHECKPRICE;
 HigherAfterEntry:=enterprice;
 LowerAfterEntry:=enterprice;
 bj:=1;
end

if holding=0  and MA5<=MA10-2 then
begin
 buySHORT(1,lots,limitr,open),IGNORECHECKPRICE;
 HigherAfterEntry:=enterprice;
 LowerAfterEntry:=enterprice;
 bj:=0;
end
if cs_kong=2 then begin
 sellshort(1,0,market);
 buy(holding=0,1,market);
 bj:=1;
 cs_kong:=0;
end

if cs_duo=2 then begin
 sell(1,0,market);
 buyshort(holding=0,1,market);
 cs_duo:=0;
 bj:=0;
end

If enterbars=0 then
begin
 HigherAfterEntry:=enterprice;
 LowerAfterEntry:=enterprice;
end;
If enterbars>=1 then
begin
 HigherAfterEntry:=max(HigherAfterEntry,h);
 LowerAfterEntry:=min(LowerAfterEntry,l);
end;

if holding>0 then price:=EnterPrice+(HigherAfterEntry-EnterPrice)*n3/100;

if holding<0 then price:=EnterPrice - (EnterPrice-LowerAfterEntry)*n3/100;

if holding>0 and enterbars>0 and  HigherAfterEntry>=enterprice*(1+N1/100) and low<=price  and bj=1 then
begin

 sell(1,holding,limitr,min(open,price)) ,IGNORECHECKPRICE;
 if numprofit(1)<0 then cs_duo:=cs_duo+1;
 if numprofit(1)>0 then cs_duo:=0;
 cs_kong:=0;
end;
if holding<0 and enterbars>0 and lowerAfterEntry<=enterprice*(1-N1/100) and  high>=price and bj=0  then
begin
 sellshort(1,holding,limitr,max(open,price)),IGNORECHECKPRICE;
 if numprofit(1)<0 then cs_kong:=cs_kong+1;
 if numprofit(1)>0 then cs_kong:=0;
 cs_duo:=0;

end;

if holding>0  and  l<=ENTERPRICE-n2 and bj=1 then 
begin
 sell(1,holding,limitr,enterprice-n2),IGNORECHECKPRICE;
  if numprofit(1)<0 then begin
   cs_duo:=cs_duo+1;
  end
   cs_kong:=0;  
end

if holding<0  and  h>=ENTERPRICE+n2 and bj=0 then 
begin
 sellshort(1,holding,limitr,enterprice+n2),IGNORECHECKPRICE;
  if numprofit(1)<0 then begin
   cs_kong:=cs_kong+1;
  end
   cs_duo:=0; 
end



金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

 回到顶部