以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]阿火的突破模型信号也会消失的问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=12494)

--  作者:wiffrey
--  发布时间:2012/6/19 14:17:35
--  [求助]阿火的突破模型信号也会消失的问题

十二、突破模型信号也会消失的一个例子及其处理方法,大家小心。

 

比如,大家常用的四周法则,一般人都是这样写的

 

//4周转向
hh:=ref(hhv(h,20),1);
ll:=ref(llv(l,20),1);

entertime:=time<=143000;

if h>hh then begin//突破高点,平空做多
 sellshort(1,1,limitr,max(o,hh+0.2)+0.6);
 buy(holding=0 and entertime,1,limitr,max(o,hh+0.2)+0.6);
end

if l<ll then begin
 sell(1,1,limitr,min(o,ll-0.2)-0.6);//突破低点,平多做空
 buyshort(holding=0 and entertime,1,limitr,min(o,ll-0.2)-0.6);
end

if time>=150000 then begin//收盘平仓
 sell(1,1,limitr,o);
 sellshort(1,1,limitr,o);
end

 

咋一看,没啥问题。其实信号也是会消失的,或者出现“才买入,又立马卖出”的情况

比如某根K线,h>hh 和 l<ll 同时成立的时候。而盘后静态来看,是看不出问题的

 

一般模型遵循的写法是先平后开,且要同时注意做多条件和做空条件同时成立时的处理 

以上模型,改写为如下,信号就不会闪烁:

//4周转向
hh:=ref(hhv(h,20),1);
ll:=ref(llv(l,20),1);

entertime:=time<=143000;

if holding<0 and h>hh then begin

 sellshort(1,1,limitr,max(o,hh+0.2)+0.6);//先是平仓

 buy(1,1,limitr,max(o,hh+0.2)+0.6);

 goto skip@;

end

if holding>0 and l<ll then begin

 sell(1,1,limitr,min(o,ll-0.2)-0.6);//先是平仓

 buyshort(1,1,limitr,min(o,ll-0.2)-0.6);

end

skip@;

//注意做多条件和做空条件同时成立的处理方法,这里采用20周期均线向上才做多,向下才做空
if holding=0 and h>hh and ref(c,1)>ref(c,20) and entertime then buy(1,1,limitr,max(o,hh+0.2)+0.6);//后开仓
if holding=0 and l<ll  and ref(c,1)<ref(c,20) and entertime then buyshort(1,1,limitr,min(o,ll-0.2)-0.6);//后开仓
if time>=150000 then begin
 sell(1,1,limitr,o);
 sellshort(1,1,limitr,o);
end

 

 

加入这个goto skip@;是什么意思,怎么按这个格式加了以后就没有开平仓信号了,

 

 

另弱弱的问一下 buy(1,1,limitr,0); 里面的两个1,

和这个里面的 SELL(1,HOLDING,LIMITR,CLOSE); 1和holding怎么解释


--  作者:just
--  发布时间:2012/6/19 15:19:29
--  

GOTO为跳转语句,在金字塔的教程中有相关说明,楼主可以去看看。

buy里第一个1的意思是条件为真,第二个1的意思是手数。

sell里第一个1的意思是条件为真,第二holding的意思是平掉所有holding持仓数量

[此贴子已经被作者于2012-6-19 15:20:28编辑过]