以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]四周规则的改写  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=9077)

--  作者:jiaoyizhe
--  发布时间:2011/11/21 22:37:51
--  [求助]四周规则的改写

HHN:=ref(HHV(HIGH,20),1);
HLN:=ref(LLV(LOW,20),1);

IF H>=HHN then
begin
sellshort(holding<0,0,thisclose);
buy(holding=0,1,thisclose);
end

IF L<=HLN then
begin
sell(holding>0,0,thisclose);
buyshort(holding=0,1,thisclose);
end

 

现在我需要使信号点位更精确一点,并且不同品种上HHN LLN需要取不同的值,例如CU ZN上取10周期, RU RB上取20周期。

 

我修改成如下写法:(没信号显示了,应该是“不同品种下HHN HLN取不同的值”的写法有问题,请帮助修改,谢谢)

 

//不同品种下HHN HLN取不同的值
variable:con:=0;
if STRCMP(STRLEFT(STKLABEL,2) ,\'CU\')=0 then con:=1;
if STRCMP(STRLEFT(STKLABEL,2) ,\'ZN\')=0 then con:=1;
HHN:=ref(HHV(HIGH,10),1);
HLN:=ref(LLV(LOW,10),1);
if con=0 then exit;


variable:con:=0;
if STRCMP(STRLEFT(STKLABEL,2) ,\'RU\')=0 then con:=2;
if STRCMP(STRLEFT(STKLABEL,2) ,\'RB\')=0 then con:=2;
HHN:=ref(HHV(HIGH,20),1);
HLN:=ref(LLV(LOW,20),1);
if con=0 then exit;


//定义确定的myprice
IF H>=HHN then
begin
myprice:=HHN;
end
IF open>=HHN then
begin
myprice:=open;
end

IF L<=HLN then
begin
myprice:=HLN;
end
IF open<=HLN then
begin
myprice:=open;
end

//公式主体
IF H>=HHN then
begin
sellshort(holding<0,0,limitr,myprice);
buy(holding=0,1,limitr,myprice);
end

IF L<=HLN then
begin
sell(holding>0,0,limitr,myprice);
buyshort(holding=0,1,limitr,myprice);//thisclose
end


--  作者:fly
--  发布时间:2011/11/22 9:10:38
--  

修改为以下

variable:con:=0;
if STRCMP(STRLEFT(STKLABEL,2) ,\'CU\')=0 then con:=1;
if STRCMP(STRLEFT(STKLABEL,2) ,\'ZN\')=0 then con:=1;

if STRCMP(STRLEFT(STKLABEL,2) ,\'RU\')=0 then con:=2;
if STRCMP(STRLEFT(STKLABEL,2) ,\'RB\')=0 then con:=2;
if con=0 then exit;


HHN:=ref(HHV(HIGH,10*con),1);
HLN:=ref(LLV(LOW,10*con),1);


--  作者:jiaoyizhe
--  发布时间:2011/11/22 10:02:55
--  

高!

 

请问单字母代码品种的限定应该如何写法?

 

variable:con:=0;
if STRCMP(STRLEFT(STKLABEL,1) ,\'M\')=0 then con:=1;
if STRCMP(STRLEFT(STKLABEL,1) ,\'P\')=0 then con:=1;

if con=0 then exit;

 

这样写好象是不对的

写M 会取到MF ME

写P  会取到PB PTA


--  作者:fly
--  发布时间:2011/11/22 10:55:19
--  
if STRCMP(STRLEFT(STKLABEL,1) ,\'M\')=0 and STRLEN(STKLABEL)=3 then con:=1;
--  作者:solarhe2006
--  发布时间:2011/11/22 15:24:40
--  [公告]上海中期北京营业部与金字塔合作

四周规则能写成VBA模板吗,方便大家学习

HHN:=ref(HHV(HIGH,20),1);
HLN:=ref(LLV(LOW,20),1);

IF H>=HHN then
begin
sellshort(holding<0,0,thisclose);
buy(holding=0,1,thisclose);
end

IF L<=HLN then
begin
sell(holding>0,0,thisclose);
buyshort(holding=0,1,thisclose);
end