以文本方式查看主题

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

--  作者:bravefist
--  发布时间:2012/8/9 9:51:28
--  程序编写问题
 

如果今天MA5>MA10,昨天MA5<MA10,那么今天算第一天,明天算第二天,在第6天的时候买入,以下编写为什么总是不对?

 

aa:=ma5>ma10 and ref(ma5,1)<ref(ma10,1);

if aa then begin

trend:=1;

daybars:=1;

end

if ref(trend,1)=1 then

daybars:=daybars+1;

if daybars=6 then

buy…

 


--  作者:rushtaotao
--  发布时间:2012/8/9 10:13:29
--  
首先均线已经写的不对了ma5没有定义吧,ma(c,5)

如果是日线上,你可以用第6天作为今天来计算,然后前面都往前推

ma5:ma (c,5);
ma10:ma(c,10);
if ref(ma5,6)<ref(ma10,6) and ref(ma5,7)>ref(ma10,7) then buy(1,1,market);