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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [求助]

   

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


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

主题:[求助]

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


加好友 发短信
等级:新手上路 帖子:96 积分:489 威望:0 精华:0 注册:2011/9/5 19:34:19
[求助]  发帖心情 Post By:2011/9/7 14:51:26    Post IP:58.247.1.214[只看该作者]

如下代码在K线图中无交易信号显示,策略测试也没有交易记录,请金字塔的老师们帮找原因

DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD1:=2*(DIFF-DEA);
LC := REF(CLOSE,1);
m1:=SMA(MAX(CLOSE-LC,0),3,1)/SMA(ABS(CLOSE-LC),3,1)*100;
m2:=-100*(HHV(HIGH,42)-CLOSE)/(HHV(HIGH,42)-LLV(LOW,42))+100;

 

enlong:=count(cross(m1,10),5)>1 and count(cross(m2,10),2)>1 and cross(diff,ref(diff,1))
  or count(cross(m1,10),2)>1 and count(cross(m2,10),5)>1 and cross(diff,ref(diff,1));//开多条件

enshort:=count(cross(90,m1),5)>1 and count(cross(90,m2),2)>1 and cross(ref(diff,1),diff)
  or count(cross(90,m1),2)>1 and count(cross(90,m2),5)>1 and cross(ref(diff,1),diff);//开空条件
exlong1:=cross(90,m1) or cross(90,m2) or cross((enterprice-c),3);//平多条件1
exshort1:=cross(m2,10) or cross(m2,10) or cross((c-enterprice),3);//平空条件1
exlong2:=barslast(enlong)>10 and (c-enterprice)<0;//平多条件2(以限价单来平仓)
exshort2:=barslast(enshort)>10 and (c-enterprice)>0;//平多条件2(以限价单来平仓)
if enlong then
  begin
  buy(holding=0,1,market);
  end
if exshort1 then
  begin
  sell(holding=1,0,market);
  end
if enshort then
  begin
  buyshort(holding=0,1,market);
  end
if exshort1 then
  begin
  sellshort(holding=-1,1,market);
  end
if exlong2 then
  begin
  sell(holding=1,0,limit,enterprice+2*mindiff);
  end
if exshort2 then
  begin
  sellshort(holding=-1,0,limit,enterprice-2*mindiff);
  end


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


加好友 发短信
等级:管理员 帖子:5082 积分:17642 威望:0 精华:6 注册:2010/7/15 9:05:58
  发帖心情 Post By:2011/9/7 15:18:56    Post IP:58.246.57.26[只看该作者]

请说明该策略适用K线周期和适用合约


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

客户服务部

-----------------------------------------------------------

欢迎您参加我公司的技术培训,具体培训需求请发邮件到

service@weistock.com

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

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


加好友 发短信
等级:新手上路 帖子:96 积分:489 威望:0 精华:0 注册:2011/9/5 19:34:19
  发帖心情 Post By:2011/9/7 15:48:36    Post IP:58.247.1.214[只看该作者]

多笔线、股指


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


加好友 发短信 大哥
等级:超级版主 帖子:2837 积分:13237 威望:0 精华:2 注册:2010/7/14 17:31:54
  发帖心情 Post By:2011/9/7 16:35:19    Post IP:58.246.57.26[只看该作者]

你写的条件太苛刻了 一直都不成立

例如enlong 从来都没成立 当然不会下单了



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

客户服务部

-----------------------------------------------------------

欢迎您参加我公司的技术培训,具体培训需求请发邮件到

service@weistock.com

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

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


加好友 发短信
等级:新手上路 帖子:96 积分:489 威望:0 精华:0 注册:2011/9/5 19:34:19
  发帖心情 Post By:2011/9/7 16:46:04    Post IP:58.247.1.214[只看该作者]

enlong:=count(cross(m1,10),5)>1 and count(cross(m2,10),2)>1 and cross(diff,ref(diff,1))
  or count(cross(m1,10),2)>1 and count(cross(m2,10),5)>1 and cross(diff,ref(diff,1));//开多条件

开多条件其实分为两个,中间有or分开。

我自己在K线图和指标中,能够看得到有开仓机会的。你可以将开仓条件的公式做成之表现来看看。


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


加好友 发短信
等级:新手上路 帖子:96 积分:489 威望:0 精华:0 注册:2011/9/5 19:34:19
  发帖心情 Post By:2011/9/7 16:53:36    Post IP:58.247.1.214[只看该作者]

 我将开仓条件改了一下,有出现开仓信号,但是平仓信号预想的一样

DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD1:=2*(DIFF-DEA);
LC := REF(CLOSE,1);
m1:=SMA(MAX(CLOSE-LC,0),3,1)/SMA(ABS(CLOSE-LC),3,1)*100;
m2:=-100*(HHV(HIGH,42)-CLOSE)/(HHV(HIGH,42)-LLV(LOW,42))+100;

 

enlong:=count(cross(m1,10),5)>=1 and count(cross(m2,10),2)>=1 and cross(diff,ref(diff,1))
  or count(cross(m1,10),2)>=1 and count(cross(m2,10),5)>=1 and cross(diff,ref(diff,1));//开多条件

enshort:=count(cross(90,m1),5)>=1 and count(cross(90,m2),2)>=1 and cross(ref(diff,1),diff)
  or count(cross(90,m1),2)>=1 and count(cross(90,m2),5)>=1 and cross(ref(diff,1),diff);//开空条件
exlong1:=cross(90,m1) or cross(90,m2) or cross((enterprice-c),3);//平多条件1
exshort1:=cross(m2,10) or cross(m2,10) or cross((c-enterprice),3);//平空条件1
exlong2:=barslast(enlong)>10 and (c-enterprice)<0;//平多条件2(以限价单来平仓)
exshort2:=barslast(enshort)>10 and (c-enterprice)>0;//平多条件2(以限价单来平仓)
if enlong then
  begin
  buy(holding=0,1,market);
  end
if exshort1 then
  begin
  sell(holding=1,0,market);
  end
if enshort then
  begin
  buyshort(holding=0,1,market);
  end
if exshort1 then
  begin
  sellshort(holding=-1,1,market);
  end
if exlong2 then
  begin
  sell(holding=1,0,limit,enterprice+2*mindiff);
  end
if exshort2 then
  begin
  sellshort(holding=-1,0,limit,enterprice-2*mindiff);
  end


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


加好友 发短信
等级:管理员 帖子:5082 积分:17642 威望:0 精华:6 注册:2010/7/15 9:05:58
  发帖心情 Post By:2011/9/7 16:55:20    Post IP:58.246.57.26[只看该作者]

那就只能跟踪你的各个条件的值来看条件是否成立了.如果开平仓条件成立,肯定会有信号的.

注意各个条件,按远近,用括号隔离开.



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

客户服务部

-----------------------------------------------------------

欢迎您参加我公司的技术培训,具体培训需求请发邮件到

service@weistock.com

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

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


加好友 发短信
等级:新手上路 帖子:96 积分:489 威望:0 精华:0 注册:2011/9/5 19:34:19
  发帖心情 Post By:2011/9/7 17:00:40    Post IP:58.247.1.214[只看该作者]

我将平仓条件做了注释,是不是语句未正确表达我的意思呢

 

DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD1:=2*(DIFF-DEA);
LC := REF(CLOSE,1);
m1:=SMA(MAX(CLOSE-LC,0),3,1)/SMA(ABS(CLOSE-LC),3,1)*100;
m2:=-100*(HHV(HIGH,42)-CLOSE)/(HHV(HIGH,42)-LLV(LOW,42))+100;

 

enlong:=count(cross(m1,10),5)>=1 and count(cross(m2,10),2)>=1 and cross(diff,ref(diff,1))
  or count(cross(m1,10),2)>=1 and count(cross(m2,10),5)>=1 and cross(diff,ref(diff,1));//开多条件

enshort:=count(cross(90,m1),5)>=1 and count(cross(90,m2),2)>=1 and cross(ref(diff,1),diff)
  or count(cross(90,m1),2)>=1 and count(cross(90,m2),5)>=1 and cross(ref(diff,1),diff);//开空条件
exlong1:=cross(90,m1) or cross(90,m2) or cross((enterprice-c),3);//平多条件1
exshort1:=cross(m2,10) or cross(m2,10) or cross((c-enterprice),3);//平空条件1
exlong2:=barslast(enlong)>10 and c<enterprice;//平多条件2(以限价单来平仓),当距离开仓K线大于10个周期,并且最新价格小于开仓价。
exshort2:=barslast(enshort)>10 and c>enterprice;//平多条件2(以限价单来平仓),当距离开仓K线大于10个周期,并且最新价格大于开仓价。
if enlong then
  begin
  buy(holding=0,1,market);
  end
if exshort1 then
  begin
  sell(holding=1,0,market);
  end
if enshort then
  begin
  buyshort(holding=0,1,market);
  end
if exshort1 then
  begin
  sellshort(holding=-1,1,market);
  end
if exlong2 then
  begin
  sell(holding=1,0,limit,enterprice+2*mindiff);
  end
if exshort2 then
  begin
  sellshort(holding=-1,0,limit,enterprice-2*mindiff);
  end


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


加好友 发短信
等级:新手上路 帖子:96 积分:489 威望:0 精华:0 注册:2011/9/5 19:34:19
  发帖心情 Post By:2011/9/8 9:29:45    Post IP:58.247.1.214[只看该作者]

开仓条件是正确的,平仓条件不是原本意思,请高手帮看看

 

DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD1:=2*(DIFF-DEA);
LC := REF(CLOSE,1);
m1:=SMA(MAX(CLOSE-LC,0),3,1)/SMA(ABS(CLOSE-LC),3,1)*100;
m2:=-100*(HHV(HIGH,42)-CLOSE)/(HHV(HIGH,42)-LLV(LOW,42))+100;

 

enlong:=count(cross(m1,10),5)>=1 and count(cross(m2,10),2)>=1 and cross(diff,ref(diff,1))
  or count(cross(m1,10),2)>=1 and count(cross(m2,10),5)>=1 and cross(diff,ref(diff,1));//开多条件

enshort:=count(cross(90,m1),5)>=1 and count(cross(90,m2),2)>=1 and cross(ref(diff,1),diff)
  or count(cross(90,m1),2)>=1 and count(cross(90,m2),5)>=1 and cross(ref(diff,1),diff);//开空条件
exlong1:=cross(90,m1) or cross(90,m2) or cross((enterprice-c),3);//平多条件1
exshort1:=cross(m2,10) or cross(m2,10) or cross((c-enterprice),3);//平空条件1
exlong2:=barslast(enlong)>10 and c<enterprice;//平多条件2(以限价单来平仓),当距离开仓K线大于10个周期,并且最新价格小于开仓价。
exshort2:=barslast(enshort)>10 and c>enterprice;//平多条件2(以限价单来平仓),当距离开仓K线大于10个周期,并且最新价格大于开仓价。
if enlong then
  begin
  buy(holding=0,1,market);
  end
if exshort1 then
  begin
  sell(holding=1,0,market);
  end
if enshort then
  begin
  buyshort(holding=0,1,market);
  end
if exshort1 then
  begin
  sellshort(holding=-1,1,market);
  end
if exlong2 then
  begin
  sell(holding=1,0,limit,enterprice+2*mindiff);
  end
if exshort2 then
  begin
  sellshort(holding=-1,0,limit,enterprice-2*mindiff);
  end



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


加好友 发短信
等级:管理员 帖子:5082 积分:17642 威望:0 精华:6 注册:2010/7/15 9:05:58
  发帖心情 Post By:2011/9/8 9:42:24    Post IP:58.246.57.26[只看该作者]

ENTERBARS>10 AND C<ENTERPRICE

当距离开仓K线大于10个周期(ENTERBARS>10 ),并且最新价格小于开仓价(C<ENTERPRICE)。

 

全部用系统函数来实现.

最多,多仓加个HOLDING>0的限制,就可以



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

客户服务部

-----------------------------------------------------------

欢迎您参加我公司的技术培训,具体培训需求请发邮件到

service@weistock.com

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

 回到顶部