应该是,每天:资产净值-现金的总和/每天:资产净值的总和。 我用WLD写了例子和WLD内置的AccountExposure结果稍有点误差。 var Bar, p : integer; var sumec,sumequity,myexposure:float; for Bar := 20 to BarCount - 1 do begin if LastPositionActive then begin p := LastPosition; SellAtStop( Bar + 1, Lowest( Bar, #Low, 10 ), p, 'Stop' ); end else begin if not LastPositionActive then begin BuyAtStop( Bar + 1, Highest( Bar, #High, 20 ), '0' ); end; end; //开始计算exposure Sumec:=Equity(Bar)-Cash(bar)+Sumec; sumequity:=sumequity+Equity(Bar); if bar=BarCount-1 then begin myexposure:=Sumec/sumequity*100; Print( floatToStr( myexposure ) ); end end; 结果再 Debug window 可看到。
原来WLD内置的AccountExposure计算方法Bar初值由0开始,把“上面的代码“for Bar := 20 to BarCount - 1 do”改为 “for Bar := 0 to BarCount - 1 do”结果和Performance报告中的Exposure将一致。 如下: var Bar, p : integer; var sumec,sumequity,myexposure:float; for Bar := 0 to BarCount - 1 do begin if Bar>=20 then begin if LastPositionActive then begin p := LastPosition; SellAtStop( Bar + 1, Lowest( Bar, #Low, 10 ), p, 'Stop' ); end else begin if not LastPositionActive then begin BuyAtStop( Bar + 1, Highest( Bar, #High, 20 ), '0' ); end; end; end; //开始计算exposure Sumec:=Equity(Bar)-Cash(bar)+Sumec; sumequity:=sumequity+Equity(Bar); if bar=BarCount-1 then begin myexposure:=Sumec/sumequity*100; Print( floatToStr( myexposure ) ); end end