以文本方式查看主题

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

--  作者:z7c9
--  发布时间:2011/1/1 15:27:46
--  [原创]PEL设计模式之模板模式

AbstractStrategy:

 

以下内容为程序代码:

1 runmode:0;
2
3 input:system(1,1,2,1);
4
5 if holding=0 then begin
6     buycond:=stkindi(stklabel,\'ContractStrategy.buycond(\'+numtostr(system,0)+\')\',0,dataperiod),linethick0;
7     buyprice:=stkindi(stklabel,\'ContractStrategy.buyprice(\'+numtostr(system,0)+\')\',0,dataperiod),linethick0;
8     buylots:=stkindi(stklabel,\'ContractStrategy.buylots(\'+numtostr(system,0)+\')\',0,dataperiod),linethick0;
9         
10     if buycond then
11         buy(1,buylots,limitr,buyprice);
12 end
13
14 if holding=0 then begin
15     buyshortcond:=stkindi(stklabel,\'ContractStrategy.buyshortcond(\'+numtostr(system,0)+\')\',0,dataperiod);
16     buyshortprice:=stkindi(stklabel,\'ContractStrategy.buyshortprice(\'+numtostr(system,0)+\')\',0,dataperiod);
17     buyshortlots:=stkindi(stklabel,\'ContractStrategy.buyshortlots(\'+numtostr(system,0)+\')\',0,dataperiod);
18     
19     if buyshortcond then
20         buyshort(1,buyshortlots,limitr,buyshortprice);
21 end
22
23 if holding>0 then begin
24     sellcond:=stkindi(stklabel,\'ContractStrategy.sellcond(\'+numtostr(system,0)+\')\',0,dataperiod);
25     sellprice:=stkindi(stklabel,\'ContractStrategy.sellprice(\'+numtostr(system,0)+\')\',0,dataperiod);
26     selllots:=stkindi(stklabel,\'ContractStrategy.selllots(\'+numtostr(system,0)+\')\',0,dataperiod);
27     
28     if sellcond then
29         sell(1,selllots,limitr,sellprice);
30 end
31
32 if holding<0 then begin
33     sellshortcond:=stkindi(stklabel,\'ContractStrategy.sellshortcond(\'+numtostr(system,0)+\')\',0,dataperiod);
34     sellshortprice:=stkindi(stklabel,\'ContractStrategy.sellshortprice(\'+numtostr(system,0)+\')\',0,dataperiod);
35     sellshortlots:=stkindi(stklabel,\'ContractStrategy.sellshortlots(\'+numtostr(system,0)+\')\',0,dataperiod);
36     
37     if sellshortcond then
38         sell(1,sellshortlots,limitr,sellshortprice);
39 end

 

ContractStrategy:

 

以下内容为程序代码:

1 runmode:0;
2
3 input:system(1,1,2,1);
4
5 buycond:if(system=1,1,if(system=2,0,0));
6 buyprice:if(system=1,close,if(system=2,open,0));
7 buylots:if(system=1,1,if(system=2,2,0));
8
9 buyshortcond:if(system=1,1,if(system=2,0,0));
10 buyshortprice:if(system=1,close,if(system=2,open,0));
11 buyshortlots:if(system=1,1,if(system=2,2,0));
12
13 sellcond:if(system=1,1,if(system=2,0,0));
14 sellprice:if(system=1,close,if(system=2,open,0));
15 selllots:if(system=1,1,if(system=2,2,0));
16
17 sellshortcond:if(system=1,1,if(system=2,0,0));
18 sellshortprice:if(system=1,close,if(system=2,open,0));
19 sellshortlots:if(system=1,1,if(system=2,2,0));
 

 

[此贴子已经被作者于2011-1-1 15:29:04编辑过]

--  作者:solarhe2006
--  发布时间:2011/8/17 0:43:40
--  [公告]上海中期北京营业部与金字塔合作
[原创]PEL设计模式之模板模式  发帖心情 Post By:2011-1-1 15:27:46

AbstractStrategy:

 

以下内容为程序代码:

1 runmode:0;
2
3 input:system(1,1,2,1);
4
5 if holding=0 then begin
6     buycond:=stkindi(stklabel,\'ContractStrategy.buycond(\'+numtostr(system,0)+\')\',0,dataperiod),linethick0;
7     buyprice:=stkindi(stklabel,\'ContractStrategy.buyprice(\'+numtostr(system,0)+\')\',0,dataperiod),linethick0;
8     buylots:=stkindi(stklabel,\'ContractStrategy.buylots(\'+numtostr(system,0)+\')\',0,dataperiod),linethick0;
9         
10     if buycond then
11         buy(1,buylots,limitr,buyprice);
12 end
13
14 if holding=0 then begin
15     buyshortcond:=stkindi(stklabel,\'ContractStrategy.buyshortcond(\'+numtostr(system,0)+\')\',0,dataperiod);
16     buyshortprice:=stkindi(stklabel,\'ContractStrategy.buyshortprice(\'+numtostr(system,0)+\')\',0,dataperiod);
17     buyshortlots:=stkindi(stklabel,\'ContractStrategy.buyshortlots(\'+numtostr(system,0)+\')\',0,dataperiod);
18     
19     if buyshortcond then
20         buyshort(1,buyshortlots,limitr,buyshortprice);
21 end
22
23 if holding>0 then begin
24     sellcond:=stkindi(stklabel,\'ContractStrategy.sellcond(\'+numtostr(system,0)+\')\',0,dataperiod);
25     sellprice:=stkindi(stklabel,\'ContractStrategy.sellprice(\'+numtostr(system,0)+\')\',0,dataperiod);
26     selllots:=stkindi(stklabel,\'ContractStrategy.selllots(\'+numtostr(system,0)+\')\',0,dataperiod);
27     
28     if sellcond then
29         sell(1,selllots,limitr,sellprice);
30 end
31
32 if holding<0 then begin
33     sellshortcond:=stkindi(stklabel,\'ContractStrategy.sellshortcond(\'+numtostr(system,0)+\')\',0,dataperiod);
34     sellshortprice:=stkindi(stklabel,\'ContractStrategy.sellshortprice(\'+numtostr(system,0)+\')\',0,dataperiod);
35     sellshortlots:=stkindi(stklabel,\'ContractStrategy.sellshortlots(\'+numtostr(system,0)+\')\',0,dataperiod);
36     
37     if sellshortcond then
38         sell(1,sellshortlots,limitr,sellshortprice);
39 end

 

ContractStrategy:

 

以下内容为程序代码:

1 runmode:0;
2
3 input:system(1,1,2,1);
4
5 buycond:if(system=1,1,if(system=2,0,0));
6 buyprice:if(system=1,close,if(system=2,open,0));
7 buylots:if(system=1,1,if(system=2,2,0));
8
9 buyshortcond:if(system=1,1,if(system=2,0,0));
10 buyshortprice:if(system=1,close,if(system=2,open,0));
11 buyshortlots:if(system=1,1,if(system=2,2,0));
12
13 sellcond:if(system=1,1,if(system=2,0,0));
14 sellprice:if(system=1,close,if(system=2,open,0));
15 selllots:if(system=1,1,if(system=2,2,0));
16
17 sellshortcond:if(system=1,1,if(system=2,0,0));
18 sellshortprice:if(system=1,close,if(system=2,open,0));
19 sellshortlots:if(system=1,1,if(system=2,2,0));
 

 


--  作者:solarhe2006
--  发布时间:2011/8/19 0:03:46
--  [公告]上海中期北京营业部与金字塔合作
引用资金:stkindi(\'stklabel\',\'HMSystem.myasset\',0,2,0),colorgreen,noaxis;