以文本方式查看主题

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

--  作者:RogarZ
--  发布时间:2012/5/2 15:00:37
--  求教模型过滤问题

 我用BOLL指标建立交易系统,想过滤信号,避免反复开平仓的问题,比如开仓后3根K线不再做交易(不平不开),3根K线后再起作用。
用exitbars信号就消失。求教改如何修改

 

我的代码:

MID :  MA(CLOSE,M);
UPPER: MID + N*STD(CLOSE,M);
LOWER: MID - N*STD(CLOSE,M);

//BOLL公式

cond1:=cross(c,lower) or cross(c,mid) or cross(c,upper);
//开多条件
cond2:=cross(lower,c) or cross(mid,c) or cross(upper,c);
//开空条件

if cond1 then
begin
sellshort(holding<0,0,mkt);//平空
buy(holding=0 ,2,mkt);//开多
end

if cond2 then
begin
sell(holding>0,0,mkt);//平多
buyshort(holding=0,2,mkt);//开空
end

 


--  作者:just
--  发布时间:2012/5/2 16:48:19
--  

MID :=  MA(CLOSE,M);
UPPER:= MID + N*STD(CLOSE,M);
LOWER:= MID - N*STD(CLOSE,M);

//BOLL公式

cond1:=cross(c,lower) or cross(c,mid) or cross(c,upper);
//开多条件
cond2:=cross(lower,c) or cross(mid,c) or cross(upper,c);
//开空条件

if cond1 and enterbars>=3 then sellshort(holding<0,0,mkt);//平空
if cond1 then buy(holding=0 ,2,mkt);//开多


if cond2 and enterbars>=3 then sell(holding>0,0,mkt);//平多
if cond2 then buyshort(holding=0,2,mkt);//开空


 


--  作者:RogarZ
--  发布时间:2012/5/3 13:36:13
--  
试了下  加了过滤信号 enterbars就一点信号都米了 求解
--  作者:just
--  发布时间:2012/5/3 13:41:15
--  
有信号 楼主仔细检查一下你的代码
--  作者:RogarZ
--  发布时间:2012/5/3 14:23:59
--  

嗯 有了
我想问下 为什么我写成

if cond1 and enterbars>=3 then
begin
sellshort(holding<0,0,mkt);//平空
buy(holding=0 ,2,mkt);//开多
end

if cond2 and enterbars>=3 then
begin
sell(holding>0,0,mkt);//平多
buyshort(holding=0,2,mkt);//开空
end

就没有信号呢 还请前辈分析下。我想了很久逻辑上觉得没问题啊~

 


--  作者:just
--  发布时间:2012/5/3 14:26:00
--  

条件不满足,你都没开仓 哪里来的ENTERBARS