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


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

   

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


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

主题:[求助]

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


 回到顶部
帅哥哟,离线,有人找我吗?
pepsi
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | 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[显示全部帖子]

多笔线、股指


 回到顶部
帅哥哟,离线,有人找我吗?
pepsi
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | 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
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | 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


 回到顶部
帅哥哟,离线,有人找我吗?
pepsi
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | 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
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | 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



 回到顶部