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


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

   

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


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

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

帅哥哟,离线,有人找我吗?
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

 回到顶部
帅哥哟,离线,有人找我吗?
zsg465341578
  2楼 | 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
  3楼 | 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


 回到顶部
帅哥哟,离线,有人找我吗?
zsg465341578
  4楼 | 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线上同时出现平仓和开仓的信号时,只有平,没有开,持仓同步也报错。

 回到顶部
帅哥哟,离线,有人找我吗?
zsg465341578
  5楼 | 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手的资金才会开?(不好意思,忘记记录下单日志了?)


 回到顶部
帅哥哟,离线,有人找我吗?
zsg465341578
  6楼 | 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手的资金,但平仓后,系统自带的持仓同步应该马上恢复持仓呀

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/20 9:22:26    Post IP:118.113.236.215[显示全部帖子]

下一步我再贴日志。如果只有1手资金,能否从公式方面解决反手不开仓的问题呢?

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/20 9:44:16    Post IP:118.113.236.215[显示全部帖子]

老师,因为刚接触股指,所以只做了1手。下一步资金不是问题,我要的是确保能够平仓的同时能够执行反手开仓的指令


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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/20 9:49:37    Post IP:118.113.236.215[显示全部帖子]

目前的情况,我先做1手,所以希望能够自动执行反手开仓

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


加好友 发短信
等级:论坛游侠 帖子:334 积分:0 威望:0 精华:0 注册:2013/8/29 9:26:12
  发帖心情 Post By:2013/11/20 10:11:18    Post IP:118.113.236.215[显示全部帖子]

老师,再请教一下,两种情况下orderqueue的写法有什么不同:一是能够自动反手就行,二是平仓和反手同时执行?

 回到顶部
总数 13 1 2 下一页