怎么写一段程序来分别计算出 交易的总盈利和总盈亏。
看过以前的帖子,问题还是没有解决,高手请帮帮忙,谢谢了
variable:a=0,b=0;
if numprofit>0 then a:=a+numprofit;
if numproft<>ref(numprofit,1) then b:=b+numprofit;
非常谢谢,在线等。。
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
自己写了下,错了 应该存在有重复计算
//用全局变量计算的总盈亏和总盈利
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;//总盈利
用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;//总盈利
100万
用2012年6月1号以来的股指连续测试上面的系统,nn:a,linethick0;//总盈亏是-149475.507 而测试报告里的总盈亏是 -130,677.88 请问 这是什么原因,净利润 和总盈亏 不应该一样吗?