Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共6 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[讨论]交易函数可否统计过去一段时间内的平均盈亏等数据

1楼
choir2001 发表于:2014/6/5 11:08:22
比如过去3个月的平均单笔盈利。现有的交易函数好像都没有时间限制。
2楼
jinzhe 发表于:2014/6/5 11:26:16
这个得要枚举计算,比较麻烦
3楼
jinzhe 发表于:2014/6/5 11:29:14
单笔盈利就是把盈利的交易做平均计算,亏损的不计算在内?
4楼
choir2001 发表于:2014/6/5 12:47:29

是的。例如AVGWIN

 

建议把常用交易统计函数都加入一个时间限定参数

5楼
jinzhe 发表于:2014/6/5 13:50:57

这里只枚举了6月份的计算方式,用户可以参考下面的写法自行编写一下其他月份的:

 

variable:ss=0;
ma5:=ma(c,5);
ma10:=ma(c,10);

if cross(ma5,ma10) then begin
 sellshort(1,0,market);
 buy(holding=0,1,market);
end

if cross(ma10,ma5) then begin
 sell(1,0,market);
 buyshort(holding=0,1,market);
end//简单的交易范例,用作计算交易盈利的样本
h1:=holding;
nn:=barslast(month=2);//计算3个月之内一共有多少根k线
yinglicishu:count(numprofit(1)>0 and h1=-1 and ref(h1,1)=1 or (h1=1 and ref(h1,1)=-1) ,nn);//盈利次数

if ((h1=-1 and ref(h1,1)=1) or (h1=1 and ref(h1,1)=-1)) and numprofit(1)>0 then ss:=ss+numprofit(1);

ss2:ss-ref(ss,nn);//3个月内的总盈利
avg_yingli:ss2/yinglicishu;

 

6楼
choir2001 发表于:2014/6/5 19:34:59
这也行,谢谢~
共6 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.01563 s, 3 queries.