求:TB系统自带的策略单元净利润资金曲线代码!我要改写进副图中

求:TB系统自带的策略单元净利润资金曲线代码!我要改写进副图中,谢谢!

参考下面的代码,小数点之后的微小差异应该是处理小数略有不同,就不用在意了Params Numeric FastLength(5);// 短期指数平均线参数 Numeric SlowLength(20);// 长期指数平均线参数 Integer slipMode(1); //滑点,0-元,1-跳 Vars Series<Numeric> AvgValue1; Series<Numeric> AvgValue2; Global Numeric slippage; Global Numeric nChartCRate; Events OnReady() { //获取滑点 Integer flag = slipMode; Bool ret = GetSlippage(flag, slippage); if(ret) { Print("slippage:" + Text(slippage)); } Else { Print("slippage:" + Text(0)); } //获取手续费 CommissionRate cRate; ret = GetCommissionRate(cRate); // 输出数值 nChartCRate = 0; If(ret) {//只考虑正常收取的情况 If(BitHas(cRate.ratioType, Enum_Rate_ByFillAmount)) { nChartCRate = cRate.openRatio / 10000; } Else If(BitHas(cRate.ratioType, Enum_Rate_AmountPerHand)) { nChartCRate = cRate.openRatio; } Else If(BitHas(cRate.ratioType, Enum_Rate_PointPerHand)) { nChartCRate = cRate.openRatio * MinMove * PriceScale * BigPointValue; } } Print("nChartCRate="+Text(nChartCRate)); } //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组 OnBar(ArrayRef<Integer> indexs) { AvgValue1 = AverageFC(Close,FastLength); AvgValue2 = AverageFC(Close,SlowLength); //PlotNumeric("MA1",AvgValue1); //PlotNumeric("MA2",AvgValue2); If(MarketPosition <>1 && AvgValue1[1] > AvgValue2[1]) { Buy(0,Open); } If(MarketPosition <>-1 && AvgValue1[1] < AvgValue2[1]) { SellShort(0,Open); } //PlotNumeric("净利润1",Portfolio_CurrentEquity-Portfolio_InitCapital); //PlotNumeric("净利",Portfolio_NetProfit); Numeric diff1 = iif(nChartCRate>0.01,ABS(CurrentContracts)*nChartCRate,ABS(CurrentContracts)*Close*contractunit*bigpointValue*nChartCRate); Numeric diff2 = slippage*MinMove*PriceScale*BigPointValue*contractUnit; Commentary("diff1="+Text(diff1)); Commentary("slippage="+Text(slippage)); Commentary("diff2="+Text(diff2)); Commentary("净利润2="+Text(Portfolio_NetProfit+Portfolio_PositionProfit)); PlotNumeric("净利润3",Portfolio_NetProfit+Portfolio_PositionProfit-diff1-diff2); }