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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 请问怎么解决反手不开仓的问题

   

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


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

主题:请问怎么解决反手不开仓的问题

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
请问怎么解决反手不开仓的问题  发帖心情 Post By:2013/11/15 0:06:40    Post IP:182.151.162.189[只看该作者]

老师你好,下面是我的交易代码示例,其中,平多条件(PD)想表达的意思是:如果开空条件已成立,即使持有多单也马上平多开空(PK亦然),这时候系统就只有平仓,没有开仓,请问是什么原因?

dif:=ema(c,12)-ema(c,26);
dea:=ema(dif,9);
macd:=2*(dif-dea);
cpx:=ma(c,14);
entertime:=time<150000 and time>091600;
exittime:=time>=151400;

//交易条件
kd:=cross(c,cpx) and cpx>ref(cpx,1) and macd>0 and entertime;//开多条件
kk:=cross(cpx,c) and cpx<ref(cpx,1) and  macd<0 and entertime;//开空条件
pd:=(macd<0 and cpx<ref(cpx,1)) or kk or exittime;//平多条件(如果开空条件成立,即使持有多单,马上平多开空
pk:=(macd>0 and cpx>ref(cpx,1)) or kd or exittime;//平空条件(如果开多条件成立,即使持有空单,马上平空开多

//交易系统 
if holding<>0 then begin
   sell(pd,0,limit,c),orderqueue;
   sellshort(pk,0,limit,c),orderqueue;
end

if holding=0 then begin
   buy(kd,1,limit,c),orderqueue;
   buyshort(kk,1,limit,c),orderqueue;
end

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


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

if holding<>0 then begin
   sell(pd,0,limit,c),orderqueue;
   sellshort(pk,0,limit,c),orderqueue;
end

if holding=0 then begin
   buy(kd,1,limit,c),orderqueue;
   buyshort(kk,1,limit,c),orderqueue;
end

 

 

这样的顺序是不正确的,软件的公式编辑界面有说明是如何写的。而且,用户是不是不明白ORDERQUEUE是用来干什么的?加上来是不是为了好看?

 

dif:=ema(c,12)-ema(c,26);
dea:=ema(dif,9);
macd:=2*(dif-dea);
cpx:=ma(c,14);
entertime:=time<150000 and time>091600;
exittime:=time>=151400;
 
kd:=cross(c,cpx) and cpx>ref(cpx,1) and macd>0 and entertime;//开多条件
kk:=cross(cpx,c) and cpx<ref(cpx,1) and  macd<0 and entertime;//开空条件
pd:=(macd<0 and cpx<ref(cpx,1)) or exittime;//平多条件(如果开空条件成立,即使持有多单,马上平多开空
pk:=(macd>0 and cpx>ref(cpx,1)) or exittime;//平空条件(如果开多条件成立

 

if kd then begin

   sellshort(1,0,thisclose);

   buy(holding=0,1,thisclose);

end

 

if kk then begin

   sell(1,0,thisclose);

   buyshort(holding=0,1,thisclose);

end

 

if pd then sell(1,0,thisclose);

if pk then sellshort(1,0,thisclose);

 



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

客户服务部

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

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

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/18 15:46:42    Post IP:222.210.224.31[只看该作者]

谢谢老师,我改过来了!如果我加上移动止赢的全局变量(YDZY),麻烦老师看一下下面的格式和逻辑对不对呢?


if ydzy=1 and holding<>0 then begin
   if h>highprice then highprice:=h;
   if (highprice-enterprice>=49 and highprice-h>=6) or (highprice-enterprice>=19 and h-enterprice<=17) then sell(1,0,limitr,c);
   if l<lowprice then lowprice:=l;
   if (enterprice-lowprice>=30 and l-lowprice>=16) or (enterprice-lowprice>=19 and enterprice-l<=13) then sellshort(1,0,limitr,c);
end

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/18 15:54:31    Post IP:222.210.224.31[只看该作者]

谢谢老师,我改过来了,如果加上移动止赢变量,麻烦老师再看看下面的公式格式和逻辑对不对?谢谢!

variable:ydzy=1;                 //移动止盈开关
variable:highprice=0,lowprice=0; //记录开仓价

if kd  then begin
   sellshort(1,0,limitr,c);
   buy(holding=0,1,limitr,c);
   highprice:=enterprice; 
end
 
if kk  then begin
   sell(1,0,limitr,c);
   buyshort(holding=0,1,limitr,c);
   lowprice:=enterprice;
end
 
if pd or enterprice-c>=10 then sell(1,0,limitr,c);
if pk or c-enterprice>=10 then sellshort(1,0,limitr,c);

if ydzy=1 and holding<>0 then begin
   if h>highprice then highprice:=h;
   if (highprice-enterprice>=49 and highprice-h>=6) or (highprice-enterprice>=19 and h-enterprice<=17) then sell(1,0,limitr,c);
   if l<lowprice then lowprice:=l;
   if (enterprice-lowprice>=30 and l-lowprice>=16) or (enterprice-lowprice>=19 and enterprice-l<=13) then sellshort(1,0,limitr,c);
end


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


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

现在是哪里不对的问题?


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

客户服务部

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

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

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/19 13:25:13    Post IP:222.211.212.174[只看该作者]

改后,现在仍是反手不开单:若一根K线上同时出现平仓和开仓的信号时,只有平,没有开,持仓同步也报错。

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


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

反手不开?资金够不够?

贴上来下单日志



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

客户服务部

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

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

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/19 13:41:24    Post IP:222.211.212.174[只看该作者]

遇到反手的时候,是不是要有2手的资金才会开?(不好意思,忘记记录下单日志了?)


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


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

是的,如果只有一手的资金,那么平空开多这样的反手动作是做不了的,因为平仓还没收到成交回报,当前账户资金不足以开反手仓


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

客户服务部

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

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

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/19 13:47:52    Post IP:222.211.212.174[只看该作者]

我只有1手的资金,但平仓后,系统自带的持仓同步应该马上恢复持仓呀

 回到顶部
总数 21 1 2 3 下一页