以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  策略编写求助区  (http://weistock.com/bbs/list.asp?boardid=11)
----  求高手帮我策略在逐K线计算模式下实现  (http://weistock.com/bbs/dispbbs.asp?boardid=11&id=7884)

--  作者:pepsi
--  发布时间:2011/9/5 19:44:18
--  求高手帮我策略在逐K线计算模式下实现

开多条件:最新价向上突破前三周期高点,一次性建立40%的仓位;

开空条件:最新价向下跌破前三周期低点,一次性建立40%的仓位;

多单止损条件:最新价向下跌破前三周期低点,一次性平仓所有多单;

空单止损条件:最新价向上突破前三周期高点,一次性平仓所有空单;

多单减仓条件:分为四次减仓,当开设多单后的第5、6、7、8周期收盘前的5分钟分别减仓10%;

空单减仓条件:分为四次减仓,当开设空单后的第5、6、7、8周期收盘前的5分钟分别减仓10%;

 

以下是我写的条件,不知道对不对,请老师们帮我看看如何才能在逐K线计算模式下完全实现以上策略,谢谢!

if enlong and holding=-4 then
  sellshort(1,4,market);//原始空单止损
if enlong and holding=0 then
  buy(1,4,market);//原始开多
if enshort and holding=4 then
  sell(1,4,market);//原始多单止损
if enshort and holding=0 then
  buyshort(1,4,market);//原始开空
exlong1:=holding=4 and barslast(enlong)=5; //减多仓条件
exlong2:=holding=3 and barslast(enlong)=6;
exlong3:=holding=2 and barslast(enlong)=7;
exlong4:=holding=1 and barslast(enlong)=8;
exshort1:=holding=-4 and barslast(enshort)=5; //空减仓条件
exshort2:=holding=-3 and barslast(enshort)=6;
exshort3:=holding=-2 and barslast(enshort)=7;
exshort4:=holding=-1 and barslast(enshort)=8;


--  作者:gxnnxxt
--  发布时间:2011/9/6 0:56:37
--  
好像有点不得要领吧,为什么是三周期?估计挣钱比较费劲
--  作者:pepsi
--  发布时间:2011/9/6 8:42:07
--  

在写此策略的时候有遇到什么问题吗


--  作者:fly
--  发布时间:2011/9/6 9:49:44
--  

//准备需要的中间变量
h3 := ref(hhv(h,3),1);
l3 := ref(llv(l,3),1);

//建立多头的进场条件
long := h>h3 and time>090100 and time<145000;


if long then
 begin
 sellshort(holding < 0, 0, thisclose);
 buy(holding = 0, 40%, limit, c+2*mindiff);
 end


//开空条件
short := l < l3 and time > 090100 and time < 145000;

if short then
 begin
 sell(holding > 0, 0, thisclose);
 buyshort(holding = 0, 40%, limit, c-2*mindiff);
 end


//减仓--每次减仓四分之一
if(enterbars=6 or enterbars=6 or enterbars=7 or enterbars=8) then
begin
sell(holding>0,25%,thisclose);
sellshort(holding<0,25%,thisclose);
end

//收盘前5分钟平仓
if time > 145500 then
 begin
 sell(holding > 0, 0,thisclose);
 sellshort(holding < 0, 0, thisclose);
 end


--  作者:pepsi
--  发布时间:2011/9/6 12:12:40
--  新湖期货实盘大赛现在开始报名
你好,此交易系统加载在K线图上未显示交易信号,策略测试也无交易记录。是策略编写问题吗?
--  作者:admin
--  发布时间:2011/9/6 17:53:12
--  
用1分钟周期试试
--  作者:pepsi
--  发布时间:2011/9/7 9:55:11
--  

图片点击可在新窗口打开查看

按照你编写的源码,在1分钟图中也不能显示信号图。且用1分钟周期测试出来的结果显示的不正常,见上图。

另外,我这个交易系统是用在日线图上的。


--  作者:fly
--  发布时间:2011/9/7 11:01:50
--  请教关于ref函数问题

//适用周期:日线
//固定时间间隔

runmode:0;

//准备需要的中间变量
h3 := ref(hhv(h,3),1);
l3 := ref(llv(l,3),1);

//建立多头的进场条件
long := h>h3;
 
if  (long and not(islastbar)) or (long and islastbar and dynainfo(207)>opentime(1)) then
 begin
 sellshort(holding < 0, 0, market);
 buy(holding = 0,40%, market);
 end


//开空条件
short := l < l3;

if (short and not(islastbar)) or (short and islastbar and dynainfo(207)>opentime(1)) then
 begin
 sell(holding > 0, 0, market);
 buyshort(holding = 0, 40%, market);
 end

//减仓--每次减仓四分之一
if (holding>0 and not(islastbar)) or (holding>0 and islastbar and dynainfo(207)>closetime(0)-500) then 
sell(enterbars=5 or enterbars=6 or enterbars=7 or enterbars=8,25%,market);
 
if (holding<0 and not(islastbar)) or (holding<0 and islastbar and dynainfo(207)>closetime(0)-500) then
sellshort(enterbars=5 or enterbars=6 or enterbars=7 or enterbars=8,25%,market);


--  作者:pepsi
--  发布时间:2011/9/7 15:27:30
--  

 (long and not(islastbar)) or (long and islastbar and dynainfo(207)>opentime(1))

这一句看不懂,麻烦解释一下

[此贴子已经被作者于2011-9-7 15:27:56编辑过]

--  作者:fly
--  发布时间:2011/9/8 9:33:56
--  

1.条件成立+不是最后一个周期

2.条件成立+最后一个周期+最新一笔的行情时间大于开盘时间