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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → 和风模板:月收益统计功能

   

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


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

主题:和风模板:月收益统计功能

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


加好友 发短信
等级:新手上路 帖子:37 积分:189 威望:0 精华:0 注册:2010/12/24 12:56:02
和风模板:月收益统计功能  发帖心情 Post By:2011/8/31 22:12:21 [只看该作者]

由于金字塔现在的模型测试中没有按月统计的功能,尝试在公式中加入简单的几行代码,实现收益按月统计,统计结果保存在txt文件中,形式如下:

macross_report IF00 月度汇总报告 测试日期:20110831
201004收益: 29940                                 
201005收益: 60780                                 
201006收益: -43680                                
201007收益: -6060                                 
201008收益: -30420                                
201009收益: 18720                                 
201010收益: 83760      

以此为模板,还可以增加每月交易次数,胜率等数据。

可以在进行回测的时候设置report参数为1,平时在图表上使用时report设为0;

                       

input:n1(5,1,100,1),n2(20,1,100,1),report(0,0,1,1);
//需要生成报告时,将参数report设为1
variable:rz1=1;
if barpos()=1 then
begin
if report=1 then
debugfile2('C:\Documents and Settings\Administrator\桌面\month.txt',FORMULANAME()&' '&stklabel&' 月度汇总报告 测试日期:%0.f',currentdate+19000000,0);
rz1:=asset();
end;

//一个均线交叉的系统作为例子
ma1:=ma(c,n1);
ma2:=ma(c,n2);
t1:=time>=091500 and time<=144500;
t2:=time>=151000;
sell(holding>0 and (ma1<ma2 or t2),1,thisclose);
sellshort(holding<0 and (ma1>ma2 or t2),1,thisclose);
buy(holding=0 and ma1>ma2 and t1,1,thisclose);
buyshort(holding=0 and ma1<ma2 and t1,1,thisclose);

//生成月统计
rz2:=ref(ASSET(),1) ;
rd:=ref(date,1);
 if barpos<>1 and (month<>ref(month,1) or islastbar) then
 begin
 if report=1 then debugfile2('C:\Documents and Settings\Administrator\桌面\month.txt',numtostr((rd+19000000)/100,0)&'收益: %0.f ',rz2-rz1,0);
    rz1:=rz2;
 end;

     
                             


以下内容只有回复后才可以浏览

版主评定:好评,获得3个金币奖励好评,获得3个金币奖励
(理由:好文章)
 回到顶部
总数 122 1 2 3 4 5 6 7 8 9 10 下一页 ..13