Rss & SiteMap

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

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

标题:怎么写一段程序来分别计算出 交易的总盈利和总盈亏。

1楼
timash 发表于:2012/12/12 19:26:53
  怎么写一段程序来分别计算出 交易的总盈利和总盈亏。 
看过以前的帖子,问题还是没有解决,高手请帮帮忙,谢谢了
2楼
jinzhe 发表于:2012/12/13 8:50:24

variable:a=0,b=0;

if numprofit>0 then a:=a+numprofit;

if numproft<>ref(numprofit,1) then b:=b+numprofit;

3楼
timash 发表于:2012/12/13 12:23:39
  请例子写详细点吧
上面的例子测试通不过

把  NUMPROFIT 改成NUMPROFIT(1)后
variable:a=0,b=0;
if NUMPROFIT(1)>0 then a:=a+NUMPROFIT(1);
if NUMPROFIT(1)<>ref(NUMPROFIT(1),1) then b:=b+NUMPROFIT(1);

无论a和b都不是总盈利、总亏损、或者总盈亏
4楼
jinzhe 发表于:2012/12/13 13:59:25
我再思考下,这个逻辑不严密
5楼
timash 发表于:2012/12/14 14:00:11
 非常谢谢,在线等。。
PC:=NUMPROFIT(0);
PROFIT:=IF(PD OR PK,IF(PC>0,PC,0),0);
COST1:=IF(PC<0,PC,0);
总盈利:=SUM(PROFIT,0),LINETHICK0;
总亏损:=SUM(COST1,0),LINETHICK0;
资产:=总盈利+总亏损,LINETHICK0
自己写了下,错了 应该存在有重复计算
6楼
jinzhe 发表于:2012/12/14 14:14:00

//用全局变量计算的总盈亏和总盈利
ma5:ma(c,5);
ma10:ma(c,10);
variable:a=0,b=0;
n1:numprofit(1),linethick0;//上次平仓盈亏

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

if cross(ma10,ma5) then begin
 sell(holding>0,0,thisclose);
 buyshort(holding=0,1,thisclose);
end
if n1<>ref(n1,1) then a:=n1+a;
if n1<>ref(n1,1) and n1>0 then b:=n1+b;
nn:a,linethick0;//总盈亏
nn1:b,linethick0;//总盈利

7楼
timash 发表于:2012/12/14 17:09:21
用2012年6月1号以来的股指连续测试上面的系统,nn:a,linethick0;//总盈亏是- 149475.507  
而测试报告里的总盈亏是 -130,677.88  
测试其他品种都有类似问题,请问 这是什么原因,净利润 和总盈亏 不应该一样吗?

//用全局变量计算的总盈亏和总盈利
ma5:ma(c,5);
ma10:ma(c,10);
RIQI:=DATE>1120601 ;
variable:a=0,b=0;
n1:numprofit(1),linethick0;//上次平仓盈亏
if cross(ma5,ma10) then begin
 sellshort( RIQI AND holding<0,0,thisclose);
 buy(RIQI AND holding=0,1,thisclose);
end
if cross(ma10,ma5) then begin
 sell(RIQI AND holding>0,0,thisclose);
 buyshort(RIQI AND holding=0,1,thisclose);
end
if n1<>ref(n1,1) then a:=n1+a;
if n1<>ref(n1,1) and n1>0 then b:=n1+b;
nn:a,linethick0;//总盈亏
nn1:b,linethick0;//总盈利

8楼
系统使用者 发表于:2012/12/16 0:22:58

应该编写总盈亏函数

9楼
timash 发表于:2012/12/17 11:34:23
   100万用2012年6月1号以来的股指连续测试上面的系统,nn:a,linethick0;//总盈亏是-149475.507  而测试报告里的总盈亏是 -130,677.88  
请问 这是什么原因,净利润 和总盈亏 不应该一样吗?

10楼
jinzhe 发表于:2012/12/17 13:16:57
有没有考虑开平仓费用?
共10 条记录, 每页显示 10 条, 页签: [1]


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