以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请教编码2  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=98504)

--  作者:c100010592
--  发布时间:2016/6/14 10:42:23
--  请教编码2
以下思路,请教怎么编码实现:

入场规则:
RAVI=绝对值(100*(7天收盘价移动平均-65天收盘价移动平均)/  65天收盘价移动平均))
1、RAVI>0.5%
2、如连续3个收盘价 > 65天收盘价移动平均, 则开多头,如连续3个收盘价  < 65天收盘价移动平均, 则开空头

出场规则:
初始止损1000元,14日新高退出空头 或 14日新低退出多头

以上在日线上运行

请教,谢谢 !

--  作者:jinzhe
--  发布时间:2016/6/14 10:50:51
--  

RAVI>0.5%

ravi是上面公式里面算出来的,还是要除以100?


--  作者:c100010592
--  发布时间:2016/6/14 10:58:53
--  
不好意思,有误,

入场规则:
RAVI=绝对值(7天收盘价移动平均-65天收盘价移动平均)/  65天收盘价移动平均)
1、RAVI>0.5%

也就是要除以100

--  作者:jinzhe
--  发布时间:2016/6/14 11:02:31
--  

ravi:abs((ma(c,7)-ma(c,65))/ma(c,65));

if ravi>0.005 and all(c>ma(c,65),3) then buy(holding=0,1,marketr);
if RAVI>0.005 and all(c<ma(c,65),3) then buyshort(holding=0,1,marketr);

if openprofit<-1000 and enterbars>0 then BEGIN
   sell(1,0,marketr);
   sellshort(1,0,marketr);
end


if h=hhv(h,14) and holding<0 then sellshort(1,0,MARKETr);
if l=llv(l,14) and holding>0 then sell(1,0,marketr);


--  作者:c100010592
--  发布时间:2016/6/14 14:15:24
--  
增加一条规则:

上次平仓后三个交易日内不开仓

这样怎么编?谢谢!

--  作者:jinzhe
--  发布时间:2016/6/14 14:27:39
--  

variabe:bj=0;

ravi:abs((ma(c,7)-ma(c,65))/ma(c,65));

if ravi>0.005 and all(c>ma(c,65),3) and bj=0 then buy(holding=0,1,marketr);
if RAVI>0.005 and all(c<ma(c,65),3) and bj=0 then buyshort(holding=0,1,marketr);

if openprofit<-1000 and enterbars>0 and holding<>0 then BEGIN
   sell(1,0,marketr);
   sellshort(1,0,marketr);

   bj:=1;
end


if h=hhv(h,14) and holding<0 then begin

    sellshort(1,0,MARKETr);

    bj:=1;

end
if l=llv(l,14) and holding>0 then begin

    sell(1,0,marketr);

    bj:=1;

end

if barslast(holding=0 and ref(holding<>0,1)) then bj:=0;