以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  [原创]完整策略模板  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=2595)

--  作者:z7c9
--  发布时间:2010/8/24 10:50:56
--  [原创]完整策略模板

以下内容为程序代码:

1 variable:maxprofit=0;
2 win:=0;
3 win2:=0;
4
5 if holding=0 then begin
6     //多头开仓
7     if tradingtime and enlongcond then begin
8         buy(1,1,limitr,close);
9         maxprofit:=0;
10     end
11     
12     //空头开仓
13     if tradingtime and enshortcond then begin
14         buyshort(1,1,limitr,close);
15         maxprofit:=0;
16     end
17 end
18
19 if holding>0 then begin
20     //多头平仓
21     if exlongcond then
22         sell(1,holding,limitr,close);
23
24     //多头收盘平仓
25     if not(tradingtime) then
26         sell(1,holding,limitr,close);
27
28     //盈亏计算
29     if enterbars>0 then begin
30         win:=(c-enterprice)/enterprice*100;
31         if win>maxprofit then
32             maxprofit:=win;
33         win2:=(maxproift-win)/maxprofit*100;
34     end
35
36     //多头初始止损
37     if win<-2 then
38         sell(1,holding,limitr,close);
39
40     //多头利润止盈
41     if win>4 then
42         sell(1,holding,limitr,close);
43     
44     //多头回撤止盈
45     if win2>60 and openprofit>0 then
46         sell(1,holding,limitr,close);
47 end
48
49 if holding<0 then begin
50     //空头平仓
51     if exshortcond then
52         sellshort(1,holding,limitr,close);
53
54     //空头收盘平仓
55     if not(tradingtime) then
56         sellshort(1,holding,limitr,close);
57     
58     //盈亏计算
59     if enterbars>0 then begin
60         win:=(enterprice-c)/enterprice*100;
61         if win>maxprofit then
62             maxprofit:=win;
63         win2:=(maxprofit-win)/maxprofit*100;
64     end
65
66     //空头初始止盈
67     if win<-2 then
68         sellshort(1,holding,limitr,close);
69
70     //空头利润止盈
71     if win>4 then
72         sellshort(1,holding,limitr,close);
73     
74     //空头回撤止盈
75     if win2>60 and openprofit>0 then
76         sellshort(1,holding,limitr,close);
77 end
78
79

[此贴子已经被作者于2010-8-24 11:01:40编辑过]

--  作者:董小球
--  发布时间:2010/8/24 11:11:00
--  
呵呵 义务奉献了
--  作者:rogerhylt
--  发布时间:2010/8/24 12:14:24
--  
经典的模板 真的不错 收藏了 Thanks
--  作者:newbasic
--  发布时间:2010/8/24 18:32:45
--  
图片点击可在新窗口打开查看
--  作者:newbasic
--  发布时间:2010/8/24 18:53:19
--  

公式测试不过去 楼主请看看原因

 

编译错误:无法判断该表达式的意图

 

箭头---        sell(1,holding,limitr,close);


--  作者:rogerhylt
--  发布时间:2010/8/24 21:19:08
--  
以下是引用newbasic在2010-8-24 18:53:19的发言:

公式测试不过去 楼主请看看原因

 

编译错误:无法判断该表达式的意图

 

箭头---        sell(1,holding,limitr,close);

别复制粘贴,需要那段 需要自己在金字塔里面打一遍。我用了止盈那一段代码:


if holding<0 then begin
 //盈亏计算
if enterbars >0 then begin
       win:=(enterprice-c)/enterprice*100;
        if win>maxprofit then
           maxprofit:=win;
         win2:=(maxprofit-win)/maxprofit*100;
        //空头初始止盈
   //if win<-2 then
       //sellshort(holding<0,holding,limitr,close); 
            //空头利润止盈
    if win>4 then
        sellshort(holding<0,holding,limitr,close);
        //空头回撤止盈
    // if win2>60 and openprofit >0 then
       // sellshort(holding<0,holding,limitr,close);
         
   end 
end

if holding>0 then begin
 //盈亏计算
if enterbars >0 then begin
       win:=(enterprice-c)/enterprice*100;
        if win>maxprofit then
           maxprofit:=win;
         win2:=(maxprofit-win)/maxprofit*100;
      //多头初始止损   
   //if win<-2 then
      // sell(holding>0,holding,limitr,close); 
      //多头利润止盈      
   if win>4 then
       sell(holding>0,holding,limitr,close);
        //多头回撤止盈
     //if win2>60 and openprofit >0 then
       // sell(holding>0,holding,limitr,close);
         
   end 
end

 

出现错误 主要是因为大于号>有问题 ,更改了一下就可以了,更改后的代码如上,你可以复制粘贴试试

 

[此贴子已经被作者于2010-8-24 21:20:16编辑过]

--  作者:rogerhylt
--  发布时间:2010/8/24 21:29:44
--  

看了一下公式区的精华帖 ,发现我用的一这段代码改编自这里

 

http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=2160图片点击可在新窗口打开查看

[此贴子已经被作者于2010-8-24 21:33:03编辑过]

--  作者:脑残
--  发布时间:2010/10/13 16:44:36
--  

1 variable:maxprofit=0;
2 win:=0;
3 win2:=0;

 

 

这3句都是什么意思啊??全不明白。请指教。


--  作者:脑残
--  发布时间:2010/10/23 20:59:24
--  
模板
--  作者:nima337
--  发布时间:2011/3/13 22:00:51
--  回复:(z7c9)[原创]完整策略模板
请问版主,这个模板能不能写在前台图表程式化用enterlong  exitlong entershort exitshort 直接替换buy sell buyshort sellshort ?