欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 策略写好,但是无法回测,请教解决方案

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有4305人关注过本帖平板打印复制链接

主题:策略写好,但是无法回测,请教解决方案

帅哥哟,离线,有人找我吗?
mikebike
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:273 积分:1215 威望:0 精华:0 注册:2011/9/27 19:56:21
策略写好,但是无法回测,请教解决方案  发帖心情 Post By:2013/2/25 23:28:49    Post IP:114.226.252.84[只看该作者]

我的策略是这样的。

〔逐K线模式〕下
一开始有部分代码,变量、序列变量赋值等等。
然后进入后面的运算时候,因为运算过度复杂,所以设定成如下:

IF NOT(ISLASTBAR) THEN EXIT;
……后面接余下的代码。
包含这段,买卖模版
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 


现在用〔训练模式〕回溯到过去的历史里看,满足条件的情况下,买卖信号确实发出了。
但是遇到如下问题:
1、当某时刻,第一次满足我的买入条件,于是策略确实提示买入了,但是到了下一根K棒,因为仍然满足我的买入条件,策略继续在提示买入。似乎完全不记得我已经在前一根K棒已经买入了?
    这是不是和我使用了IF NOT(ISLASTBAR) THEN EXIT;有关系呢?
    为什么前面的已经持仓未被记住呢?
2、可能因为1的缘故,在历史数据回测时候,报告中没有任何一笔交易……因此无法回测了……

请高手稍微指导一下这个菜鸟级的问题。
[此贴子已经被作者于2013-2-25 23:29:43编辑过]

 回到顶部
总数 11 1 2 下一页