以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  为什么文华公式改成金字塔的显示结果就不一样了呢?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=222)

--  作者:kedeguo
--  发布时间:2009/11/21 22:22:28
--  为什么文华公式改成金字塔的显示结果就不一样了呢?

请老师帮忙看一下!N:=BARSLAST(DATE<>REF(DATE,1))+1;
H1:=VALUEWHEN(TIME=091300,HHV(H,N));
L1:=VALUEWHEN(TIME=091300,LLV(L,N));
HH1:=VALUEWHEN(N>30,HHV(H,30));
LL1:=VALUEWHEN(N>30,LLV(L,30));
ABK:=C>H1;
ASK:=C<L1;
CBK:=C>REF(HH1,1);
CSK:=C<REF(LL1,1);
ABK1:=IF(CROSS(C,H1),1,0);
ASK1:=IF(CROSS(L1,C),1,0);
CBK1:=IF(CROSS(C,REF(HH1,1)),1,0);
CSK1:=IF(CROSS(REF(LL1,1),C),1,0);
BBK:=IF(N<=14,0,SUM(ABK1,N-14));
BSK:=IF(N<=14,0,SUM(ASK1,N-14));
DBK:=IF(N<=31,0,SUM(CBK1,N-31));
DSK:=IF(N<=31,0,SUM(CSK1,N-31));
BK:=((ABK AND TIME>=091300 AND TIME<093000)OR(CBK AND TIME>=093000)) AND ( (BBK<=1 AND BSK<1 AND DSK<1)OR(DBK<=1 AND BSK<1 AND DSK<1) ) AND TIME<145700;
 SP:=(ASK AND TIME>=091300 AND TIME<093000)OR(CSK AND TIME>=093000) OR TIME>=145700;
SK:=((ASK AND TIME>=091300 AND TIME<093000)OR(CSK AND TIME>=093000)) AND ( (BSK<=1 AND BBK<1 AND DBK<1)OR(DSK<=1 AND BBK<1 AND DBK<1) ) AND TIME<145700;
 BP:=(ABK AND TIME>=091300 AND TIME<093000)OR(CBK AND TIME>=093000) OR TIME>=145700;
BUY(BK,10%,0);
SELL(SP,0);
BUYSHORT(SK,10%,0);
SELLSHORT(BP,0);


--  作者:admin
--  发布时间:2009/11/21 22:29:11
--  
没看出来有什么问题,请问可否具体指出来?
--  作者:金字塔
--  发布时间:2009/11/21 23:12:54
--  

请试一试这个

N:=BARSLAST(DATE<>REF(DATE,1))+1;
H1:=VALUEWHEN(TIME=091300,HHV(H,N));
L1:=VALUEWHEN(TIME=091300,LLV(L,N));
HH1:=VALUEWHEN(N>30,HHV(H,30));
LL1:=VALUEWHEN(N>30,LLV(L,30));
ABK:=C>H1;
ASK:=C<L1;
CBK:=C>REF(HH1,1);
CSK:=C<REF(LL1,1);
ABK1:=IF(CROSS(C,H1),1,0);
ASK1:=IF(CROSS(L1,C),1,0);
CBK1:=IF(CROSS(C,REF(HH1,1)),1,0);
CSK1:=IF(CROSS(REF(LL1,1),C),1,0);
BBK:=IF(N<=14,0,SUM(ABK1,N-14));
BSK:=IF(N<=14,0,SUM(ASK1,N-14));
DBK:=IF(N<=31,0,SUM(CBK1,N-31));
DSK:=IF(N<=31,0,SUM(CSK1,N-31));
BK:=FILTER(((ABK AND TIME>=091300 AND TIME<093000)OR(CBK AND TIME>=093000)) AND ( (BBK<=1 AND BSK<1 AND DSK<1)OR(DBK<=1 AND BSK<1 AND DSK<1) ) AND TIME<145700 ,20 );
 SP:=(ASK AND TIME>=091300 AND TIME<093000)OR(CSK AND TIME>=093000) OR TIME>=145700;
SK:=FILTER(((ASK AND TIME>=091300 AND TIME<093000)OR(CSK AND TIME>=093000)) AND ( (BSK<=1 AND BBK<1 AND DBK<1)OR(DSK<=1 AND BBK<1 AND DBK<1) ) AND TIME<145700 ,20 );
 BP:=(ABK AND TIME>=091300 AND TIME<093000)OR(CBK AND TIME>=093000) OR TIME>=145700;
BUY(BK,10%,0);
SELL(SP,0);
BUYSHORT(SK,10%,0);
SELLSHORT(BP,0);


--  作者:kedeguo
--  发布时间:2009/11/22 10:14:43
--  

这个是我文华财经里面用来日内交易的,是一分钟图形下的。符合条件以后,一天仅进行一次开平。根据模型,应该说每天都有符合开仓条件的。你帮我改过的好像没达到哪效果。


--  作者:金字塔
--  发布时间:2009/11/22 10:55:27
--  

若是符合条件以后,一天仅进行一次开平。可将代码最后4句换成下列5句,试试。

 

持仓:HOLDING,LINETHICK0;

SELLSHORT(BP,0);

BUY(BK AND 持仓=0,10%,0);
SELL(SP,0);
BUYSHORT(SK AND 持仓=0,10%,0);


--  作者:kedeguo
--  发布时间:2009/11/22 16:12:51
--  

我的一天只进行一次开平是针对某一个合约而言的,不是针对账户。持仓=0?这里应该不太对吧


--  作者:金字塔
--  发布时间:2009/11/22 16:27:11
--  

那还是用这个

BK:=FILTER(((ABK AND TIME>=091300 AND TIME<093000)OR(CBK AND TIME>=093000)) AND ( (BBK<=1 AND BSK<1 AND DSK<1)OR(DBK<=1 AND BSK<1 AND DSK<1) ) AND TIME<145700 ,230 );
 SP:=(ASK AND TIME>=091300 AND TIME<093000)OR(CSK AND TIME>=093000) OR TIME>=145700;
SK:=FILTER(((ASK AND TIME>=091300 AND TIME<093000)OR(CSK AND TIME>=093000)) AND ( (BSK<=1 AND BBK<1 AND DBK<1)OR(DSK<=1 AND BBK<1 AND DBK<1) ) AND TIME<145700 ,230 );
 BP:=(ABK AND TIME>=091300 AND TIME<093000)OR(CBK AND TIME>=093000) OR TIME>=145700;

SELLSHORT(BP,0);
BUY(BK,10%,0);
SELL(SP,0);
BUYSHORT(SK,10%,0);
请注意最后4句的次序,逻辑上先平后开

 

[此贴子已经被作者于2009-11-22 16:30:02编辑过]