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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 请教:当赢利>=1%,回吐到70%平仓,问题在哪

   

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


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

主题:请教:当赢利>=1%,回吐到70%平仓,问题在哪

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


加好友 发短信
等级:新手上路 帖子:24 积分:0 威望:0 精华:0 注册:2013/9/22 14:24:24
请教:当赢利>=1%,回吐到70%平仓,问题在哪  发帖心情 Post By:2013/9/22 15:27:23    Post IP:111.73.25.95[只看该作者]

基本思路,就是根据开盘价,比开盘价高N1就开多,低N1开空,价格亏损N2元就止损,赢利超过0.5%-1% ,回吐到50%平仓,赢利超过1%,回吐到70%平仓,第一次平仓是对的,再次开仓之后的平仓就不行了,开仓即平。


variable:HigherAfterEntry=0,LowerAfterEntry=999999;


input:n1(10,5,30,1);
input:n2(20,5,40,1);
input:n6(6,4,30,1);
input:n7(2,1,20,1);


//9点开仓

open5_1:callstock('',vtopen,2,-1);//5分钟周期的开盘价
close5_1:callstock('',vtclose,2,-1);//5分钟周期的收盘价

open3_1:callstock('',vtopen,17,-1);//3分钟周期的开盘价
close3_1:callstock('',vtclose,17,-1);//3分钟周期的收盘价

vols20_1:=callstock('',vtvol,22,20);//20秒周期的成交量
vol1_1:=callstock('',vtvol,1,-1);//1分钟周期的成交量


dayopen:=valuewhen(time=130100,open);

开盘价:=dayopen,noaxis,linethick0;
成交量:=REF(vol,1),noaxis,linethick0;

if time=130100 then
begin

loss:=0; //限制开仓方式一,只开一次
count1:=1;
count2:=1;

end

计数一:=count1,noaxis,linethick0;
计数二:=count2,noaxis,linethick0;
计数三:=loss,noaxis,linethick0;

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

c_1:=ref(c,1);

o_1:=ref(o,1);

vol_1:=ref(vol,1);

vol_2:=ref(vol,2);

vol_3:=ref(vol,3);

vol_4:=ref(vol,4);

sumvol:vol_2+vol_3+vol_4,noaxis,linethick0;

lots:=1;

if time>=130000 and holding=0 and count1=1 and loss=0 then

 begin
 
 if h>=dayopen+n1 
 then
 begin
 buy(1,lots,limitr,dayopen+n1);  //如果9:00走势超过开盘价n1元就开多单
 count1:=0;
 loss:=1;
 end
 
 if l<=dayopen-n1 
 
   then
   begin
   buyshort(1,lots,limitr,dayopen-n1); //9:00走势低于开盘
价n1元就开空单
   count1:=0;
   loss:=1;
   end
 
 end
 
 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 time>=130101 and time<180000  then
 
 BEGIN
 
 if holding>0  and  l<=ENTERPRICE-n2
 
 then 
 begin
 sell(1,holding,limitr,enterprice-n2); //9.00开多单,止损设置低于成交价n2元

 end
 
 if holding<0  and  h>=ENTERPRICE+n2
 then 
 begin
 sellshort(1,holding,limitr,enterprice+n2); //9.00开空单,止损设置高于成交价n2元

 end
 
 end 
 
 
 再次开多、空仓

………………

 

 
 //开多单的平仓
 
 if holding>0 and enterbars>0  then
 
 begin
 
 

 
 if  enterbars>=1  and HigherAfterEntry>=enterprice*(1+1/100)       //成交赢利超过1%,回吐到70%出场
 then
 begin
 price:=EnterPrice+(HigherAfterEntry-EnterPrice)*70/100;
 if low<=price then
 begin
 sell(1,holding,limitr,min(open,price)) ;
 count2:=1;
 end;
 end;
 
if  enterbars>=1   and HigherAfterEntry<=enterprice*(1+1/100) and HigherAfterEntry>=enterprice*(1+0.5/100)       //成交赢利不超过1%,大于0.5%,回吐到50%出场
 then
 begin
 price:=EnterPrice+(HigherAfterEntry-EnterPrice)*50/100;
 if low<=price then
 begin
 sell(1,holding,limitr,min(open,price)) ;
  count2:=1;
 end;
 end;
 
 end
 
 
//开空单的平仓
 
 if holding<0 and enterbars>0  then
 
 begin
 
 
 
 if  enterbars>=1    and lowerAfterEntry<=enterprice*(1-1/100)       //成交赢利超过1%,回吐到70%赢利出场
 then
 begin
 price:=EnterPrice - (EnterPrice-LowerAfterEntry)*70/100;
 if high>=price then
 begin
 sellshort(1,holding,limitr,max(open,price)) ;
  count2:=1;
 end;
 end;
 
  if  enterbars>=1   and lowerAfterEntry>=enterprice*(1-1/100)  and lowerAfterEntry<=enterprice*(1-0.5/100)      //成交赢利不超过1%,大于0.5%,回吐到50%出场
 then
 begin
 price:=EnterPrice - (EnterPrice-LowerAfterEntry)*50/100;
 if high>=price then
 begin
 sellshort(1,holding,limitr,max(open,price)) ;
 count2:=1;
 end;
 end;
 
 end
 
 

 
 
 //收盘平仓
if time>=183000 then begin
  sell(1,holding,thisclose);
  sellshort(1,holding,thisclose);
end
 


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


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

下单价格不合理,价格超出k线范围,导致了该单子被系统检测为无法成交的单子,所以要在所有下单函数语句后面加上,IGNORECHECKPRICE

 

下面是经过修改后的代码:

 

variable:HigherAfterEntry=0,LowerAfterEntry=999999;


input:n1(10,5,30,1);
input:n2(20,5,40,1);
input:n6(6,4,30,1);
input:n7(2,1,20,1);


//9点开仓

open5_1:callstock('',vtopen,2,-1);//5分钟周期的开盘价
close5_1:callstock('',vtclose,2,-1);//5分钟周期的收盘价

open3_1:callstock('',vtopen,17,-1);//3分钟周期的开盘价
close3_1:callstock('',vtclose,17,-1);//3分钟周期的收盘价

vols20_1:=callstock('',vtvol,22,20);//20秒周期的成交量
vol1_1:=callstock('',vtvol,1,-1);//1分钟周期的成交量


dayopen:=valuewhen(time=130100,open);

开盘价:=dayopen,noaxis,linethick0;
成交量:=REF(vol,1),noaxis,linethick0;

if time=130100 then
begin

loss:=0; //限制开仓方式一,只开一次
count1:=1;
count2:=1;

end

计数一:=count1,noaxis,linethick0;
计数二:=count2,noaxis,linethick0;
计数三:=loss,noaxis,linethick0;

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

c_1:=ref(c,1);

o_1:=ref(o,1);

vol_1:=ref(vol,1);

vol_2:=ref(vol,2);

vol_3:=ref(vol,3);

vol_4:=ref(vol,4);

sumvol:vol_2+vol_3+vol_4,noaxis,linethick0;

lots:=1;

if time>=130000 and holding=0 and count1=1 and loss=0 then

 begin
 
 if h>=dayopen+n1 
 then
 begin
 buy(1,lots,limitr,dayopen+n1),IGNORECHECKPRICE;  //如果9:00走势超过开盘价n1元就开多单
 count1:=0;
 loss:=1;
 end
 
 if l<=dayopen-n1 
 
   then
   begin
   buyshort(1,lots,limitr,dayopen-n1),IGNORECHECKPRICE; //9:00走势低于开盘价n1元就开空单
   count1:=0;
   loss:=1;
   end
 
 end
 
 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 time>=130101 and time<180000  then
 
 BEGIN
 
 if holding>0  and  l<=ENTERPRICE-n2
 
 then 
 begin
 sell(1,holding,limitr,enterprice-n2),IGNORECHECKPRICE; //9.00开多单,止损设置低于成交价n2元

 end
 
 if holding<0  and  h>=ENTERPRICE+n2
 then 
 begin
 sellshort(1,holding,limitr,enterprice+n2),IGNORECHECKPRICE; //9.00开空单,止损设置高于成交价n2元

 end
 
 end
 
 

 

 
 //开多单的平仓
 
 if holding>0 and enterbars>0  then
 
 begin
 
 

 
 if  enterbars>=1  and HigherAfterEntry>=enterprice*(1+1/100)       //成交赢利超过1%,回吐到70%出场
 then
 begin
 price:=EnterPrice+(HigherAfterEntry-EnterPrice)*70/100;
 if low<=price then
 begin
 sell(1,holding,limitr,min(open,price)),IGNORECHECKPRICE ;
 count2:=1;
 end;
 end;
 
if  enterbars>=1   and HigherAfterEntry<=enterprice*(1+1/100) and HigherAfterEntry>=enterprice*(1+0.5/100)       //成交赢利不超过1%,大于0.5%,回吐到50%出场
 then
 begin
 price:=EnterPrice+(HigherAfterEntry-EnterPrice)*50/100;
 if low<=price then
 begin
 sell(1,holding,limitr,min(open,price)),IGNORECHECKPRICE ;
  count2:=1;
 end;
 end;
 
 end
 
 
//开空单的平仓
 
 if holding<0 and enterbars>0  then
 
 begin
 
 
 
 if  enterbars>=1    and lowerAfterEntry<=enterprice*(1-1/100)       //成交赢利超过1%,回吐到70%赢利出场
 then
 begin
 price:=EnterPrice - (EnterPrice-LowerAfterEntry)*70/100;
 if high>=price then
 begin
 sellshort(1,holding,limitr,max(open,price)) ,IGNORECHECKPRICE;
  count2:=1;
 end;
 end;
 
  if  enterbars>=1   and lowerAfterEntry>=enterprice*(1-1/100)  and lowerAfterEntry<=enterprice*(1-0.5/100)      //成交赢利不超过1%,大于0.5%,回吐到50%出场
 then
 begin
 price:=EnterPrice - (EnterPrice-LowerAfterEntry)*50/100;
 if high>=price then
 begin
 sellshort(1,holding,limitr,max(open,price)) ,IGNORECHECKPRICE;
 count2:=1;
 end;
 end;
 
 end
 
 

 
 
 //收盘平仓
if time>=183000 then begin
  sell(1,holding,thisclose);
  sellshort(1,holding,thisclose);
end



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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:24 积分:0 威望:0 精华:0 注册:2013/9/22 14:24:24
添加了IGNORECHECKPRICE函数,也没有用,是怎么回事,请帮帮忙  发帖心情 Post By:2013/9/22 18:00:11    Post IP:111.73.25.95[只看该作者]

添加了IGNORECHECKPRICE函数,也没有用,是怎么回事,请帮帮忙,图形仍是一样的

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


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

编译过了没?


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

客户服务部

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

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

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


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

把现在的截图发一下

按照下面的方式进行贴图



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

客户服务部

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

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

 回到顶部