Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共10 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]

1楼
pepsi 发表于:2011/9/7 14:51:26

如下代码在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

2楼
fly 发表于:2011/9/7 15:18:56
请说明该策略适用K线周期和适用合约
3楼
pepsi 发表于:2011/9/7 15:48:36

多笔线、股指

4楼
董小球 发表于:2011/9/7 16:35:19

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

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

5楼
pepsi 发表于:2011/9/7 16:46:04

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线图和指标中,能够看得到有开仓机会的。你可以将开仓条件的公式做成之表现来看看。

6楼
pepsi 发表于:2011/9/7 16:53:36

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

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

7楼
fly 发表于:2011/9/7 16:55:20

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

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

8楼
pepsi 发表于:2011/9/7 17:00:40

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

 

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

9楼
pepsi 发表于:2011/9/8 9:29:45

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

 

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


10楼
fly 发表于:2011/9/8 9:42:24

ENTERBARS>10 AND C<ENTERPRICE

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

 

全部用系统函数来实现.

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

共10 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.04688 s, 3 queries.