开仓金额与收益率的问题

策略里设置了资金动态权益2000000元(2百万),思路是根据条件,半仓至全仓操作,回测盈利15363347元,怎么年化收益率是76.82%,而不是7.6倍,策略报告里初始资金怎么显示2千万?

代码22行、73行为设置仓位。

图标上显示开仓位置及开仓价格与实际开仓不一致的问题
请问开仓资金额亏损10%止损,盈利20%止盈的代码是什么?
回测收益率计算问题
开仓金额与公式中保证金 策略单元设置中初始资金的关系
关于年化收益率的疑问
tbpy中的成交金额
1跳的金额是多少?
策略组合报告的年化收益率计算
分别计算多个合约买入后的收益率
回测与实盘开仓价不一致

你初始资金就设置错了,去看看帮助文档的《四周规则交易策略》

https://tbq3.tbquant.net/helper?product_id=991&keyword=3507&content_id=30&selectedkey=443&type=article

这好像根本没有设置初始资金。

只是设置了一个貌似代表初始资金的参数而已,并没有对单元的初始资金进行设置。

所以后面调用的权益都是单元默认的2000万。

//------------------------------------------------------------------------

// 简称: test_LS_Crossduaemama

// 名称: wu

// 类别: 策略应用

// 类型: 用户应用

// 输出: Void

//------------------------------------------------------------------------

//------------------------------------------------------------------------

// 简称: LS_CrossCycleDualEmaMa

// 名称: 跨周期混合双均线双向策略

// 类别: 策略应用

// 类型: 用户应用

// 输出: Void

//------------------------------------------------------------------------

Params

   Numeric LengthFast00(5);//0图层短周期参数

   Numeric LengthSlow00(20);//0图层长周期参数

   Numeric LengthFast01(5);//1图层短周期参数

   Numeric LengthSlow01(20);//1图层长周期参数

   Numeric LengthFast2(5);//日线短周期参数

   Numeric LengthSlow2(10);//日线长周期参数    

   Numeric TotalCapital(2000000);//动态权益

   

Vars

   Series<Numeric> EMAFast00;

   Series<Numeric> MASlow00;

   Series<Numeric> EMAFast01;

   Series<Numeric> MASlow01;

   Series<Numeric> MAFast2;

   Series<Numeric> MASlow2;

   Series<Numeric> MinPositionLots;

   Series<Numeric> FundPositionLots;

   

Events

   

   OnInit()

   {

       Range[0:DataCount - 1]

       {

           AddDataFlag(Enum_Data_RolloverBackWard());   //设置后复权

           AddDataFlag(Enum_Data_RolloverRealPrice());  //真实价格

           AddDataFlag(Enum_Data_AutoSwapPosition());  //自动换仓

           AddDataFlag(Enum_Data_IgnoreSwapSignalCalc());  //忽略换仓信号计算

       }

       Numeric i;

       Numeric result = 1;

   

       for i = 0 to DataSourceSize - 1

       {

           result = result * data[i].BarExistStatus;

       }

       If(result <> 1) Return;//数据未到齐,终止本次运行,等待下次

   }

   

   OnBar(ArrayRef<Integer> indexs)

   {

       EMAFast00 = XAverage(Close, LengthFast00);

       MASlow00 = Average(Close, LengthSlow00);

   

       Data1.EMAFast01 = Data1.XAverage(Data1.Close, LengthFast01);

       Data1.MASlow01 = Data1.Average(Data1.Close, LengthSlow01);

   

       Data2.MAFast2 = Data2.Average(Data2.Close, LengthFast2);

       Data2.MASlow2 = Data2.Average(Data2.Close, LengthSlow2);

   

       PlotNumeric("EMAFast00", EMAFast00);

       PlotNumeric("MASlow00", MASlow00);

       Data1.PlotNumeric("Data1.EMAFast01", Data1.EMAFast01);

       Data1.PlotNumeric("Data1.MASlow01", Data1.MASlow01);

       Data2.PlotNumeric("Data2.MAFast2", Data2.MAFast2);

       Data2.PlotNumeric("Data2.MASlow2", Data2.MASlow2);

       

       MinPositionLots = 0.5*Max(1, IntPart(TotalCapital / (Open / Rollover *ContractUnit *BigPointValue * MarginRatio)));

   

       If(MarketPosition <> 1 And Data2.MAFast2[1] >= Data2.MASlow2[1] And EMAFast00[2] < MASlow00[2] And EMAFast00[1] >= MASlow00[1])

       {

           FundPositionLots = 2 * MinPositionLots;

           Buy(FundPositionLots, Open);

       }

   

       If(MarketPosition <> 1 And Data2.MAFast2[1] < Data2.MASlow2[1] And EMAFast00[2] < MASlow00[2] And EMAFast00[1] >= MASlow00[1])

       {

           FundPositionLots = MinPositionLots;

           Buy(FundPositionLots, Open);

       }

   

       If(MarketPosition <> 1 And Data2.MAFast2[1] >= Data2.MASlow2[1] And Data1.EMAFast01[2] < Data1.MASlow01[2] And Data1.EMAFast01[1] >= Data1.MASlow01[1] And EMAFast00[1] >= MASlow00[1])

       {

           FundPositionLots = 2 * MinPositionLots;

           Buy(FundPositionLots, Open);

       }

   

       If(MarketPosition <> 1 And Data2.MAFast2[1] < Data2.MASlow2[1] And Data1.EMAFast01[2] < Data1.MASlow01[2] And Data1.EMAFast01[1] >= Data1.MASlow01[1] And EMAFast00[1] >= MASlow00[1])

       {

           FundPositionLots = MinPositionLots;

           Buy(FundPositionLots, Open);

       }

   

       If(MarketPosition == 1 and BarsSinceEntry > 0  And EMAFast00[2] >= MASlow00[2] And EMAFast00[1] < MASlow00[1])

       {

           Sell(FundPositionLots, Open);

       }

   

       If(MarketPosition <> -1 And Data2.MAFast2[1] < Data2.MASlow2[1] And Data1.EMAFast01[2] > Data1.MASlow01[2] And Data1.EMAFast01[1] < Data1.MASlow01[1])

       {

           FundPositionLots = 2 * MinPositionLots;

           SellShort(FundPositionLots, Open);

       }

   

       If(MarketPosition <> -1 And Data2.MAFast2[1] > Data2.MASlow2[1] And Data1.EMAFast01[2] > Data1.MASlow01[2] And Data1.EMAFast01[1] <= Data1.MASlow01[1])

       {

           FundPositionLots = MinPositionLots;

           SellShort(FundPositionLots, Open);

       }

   

       If(MarketPosition <> -1 And Data2.MAFast2[1] < Data2.MASlow2[1] And EMAFast00[2] > MASlow00[2] And EMAFast00[1] < MASlow00[1] And Data1.EMAFast01[1] <= Data1.MASlow01[1])

       {

           FundPositionLots = 2 * MinPositionLots;

           SellShort(FundPositionLots, Open);

       }

   

       If(MarketPosition <> -1 And Data2.MAFast2[1] > Data2.MASlow2[1] And EMAFast00[2] > MASlow00[2] And EMAFast00[1] < MASlow00[1] And Data1.EMAFast01[1] <= Data1.MASlow01[1])

       {

           FundPositionLots = MinPositionLots;

           SellShort(FundPositionLots, Open);

       }

   

       If(MarketPosition == -1 and BarsSinceEntry > 0 And Data1.EMAFast01[2] <= Data1.MASlow01[2] And Data1.EMAFast01[1] > Data1.MASlow01[1])

       {

           BuyToCover(FundPositionLots, Open);

       }

   }

//------------------------------------------------------------------------

// 编译版本    2025/11/7 154009

// 版权所有    winter110

// 更改声明    TradeBlazer Software保留对TradeBlazer平台

//            每一版本的TradeBlazer策略修改和重写的权利

//------------------------------------------------------------------------

//------------------------------------------------------------------------

// 编译版本    2025/11/8 142324

// 版权所有    winter110

// 更改声明    TradeBlazer Software保留对TradeBlazer平台

//            每一版本的TradeBlazer策略修改和重写的权利

//------------------------------------------------------------------------

使用的参数15、150、60、165、5、10。级别5分、5分、日。是不是设置仓位的公式有问题呢?

//------------------------------------------------------------------------

// 简称: test_LS_Crossduaemama

// 名称: wu

// 类别: 策略应用

// 类型: 用户应用

// 输出: Void

//------------------------------------------------------------------------

//------------------------------------------------------------------------

// 简称: LS_CrossCycleDualEmaMa

// 名称: 跨周期混合双均线双向策略

// 类别: 策略应用

// 类型: 用户应用

// 输出: Void

//------------------------------------------------------------------------

Params

   Numeric LengthFast00(5);//0图层短周期参数

   Numeric LengthSlow00(20);//0图层长周期参数

   Numeric LengthFast01(5);//1图层短周期参数

   Numeric LengthSlow01(20);//1图层长周期参数

   Numeric LengthFast2(5);//日线短周期参数

   Numeric LengthSlow2(10);//日线长周期参数    

   Numeric TotalCapital(2000000);//动态权益

   

Vars

   Series<Numeric> EMAFast00;

   Series<Numeric> MASlow00;

   Series<Numeric> EMAFast01;

   Series<Numeric> MASlow01;

   Series<Numeric> MAFast2;

   Series<Numeric> MASlow2;

   Series<Numeric> MinPositionLots;

   Series<Numeric> FundPositionLots;

   

Events

   

   OnInit()

   {

       Range[0:DataCount - 1]

       {

           AddDataFlag(Enum_Data_RolloverBackWard());   //设置后复权

           AddDataFlag(Enum_Data_RolloverRealPrice());  //真实价格

           AddDataFlag(Enum_Data_AutoSwapPosition());  //自动换仓

           AddDataFlag(Enum_Data_IgnoreSwapSignalCalc());  //忽略换仓信号计算

       }

       Numeric i;

       Numeric result = 1;

   

       for i = 0 to DataSourceSize - 1

       {

           result = result * data[i].BarExistStatus;

       }

       If(result <> 1) Return;//数据未到齐,终止本次运行,等待下次

   }

   

   OnBar(ArrayRef<Integer> indexs)

   {

       EMAFast00 = XAverage(Close, LengthFast00);

       MASlow00 = Average(Close, LengthSlow00);

   

       Data1.EMAFast01 = Data1.XAverage(Data1.Close, LengthFast01);

       Data1.MASlow01 = Data1.Average(Data1.Close, LengthSlow01);

   

       Data2.MAFast2 = Data2.Average(Data2.Close, LengthFast2);

       Data2.MASlow2 = Data2.Average(Data2.Close, LengthSlow2);

   

       PlotNumeric("EMAFast00", EMAFast00);

       PlotNumeric("MASlow00", MASlow00);

       Data1.PlotNumeric("Data1.EMAFast01", Data1.EMAFast01);

       Data1.PlotNumeric("Data1.MASlow01", Data1.MASlow01);

       Data2.PlotNumeric("Data2.MAFast2", Data2.MAFast2);

       Data2.PlotNumeric("Data2.MASlow2", Data2.MASlow2);

       

       MinPositionLots = 0.5*Max(1, IntPart(TotalCapital / (Open / Rollover *ContractUnit *BigPointValue * MarginRatio)));

   

       If(MarketPosition <> 1 And Data2.MAFast2[1] >= Data2.MASlow2[1] And EMAFast00[2] < MASlow00[2] And EMAFast00[1] >= MASlow00[1])

       {

           FundPositionLots = 2 * MinPositionLots;

           Buy(FundPositionLots, Open);

       }

   

       If(MarketPosition <> 1 And Data2.MAFast2[1] < Data2.MASlow2[1] And EMAFast00[2] < MASlow00[2] And EMAFast00[1] >= MASlow00[1])

       {

           FundPositionLots = MinPositionLots;

           Buy(FundPositionLots, Open);

       }

   

       If(MarketPosition <> 1 And Data2.MAFast2[1] >= Data2.MASlow2[1] And Data1.EMAFast01[2] < Data1.MASlow01[2] And Data1.EMAFast01[1] >= Data1.MASlow01[1] And EMAFast00[1] >= MASlow00[1])

       {

           FundPositionLots = 2 * MinPositionLots;

           Buy(FundPositionLots, Open);

       }

   

       If(MarketPosition <> 1 And Data2.MAFast2[1] < Data2.MASlow2[1] And Data1.EMAFast01[2] < Data1.MASlow01[2] And Data1.EMAFast01[1] >= Data1.MASlow01[1] And EMAFast00[1] >= MASlow00[1])

       {

           FundPositionLots = MinPositionLots;

           Buy(FundPositionLots, Open);

       }

   

       If(MarketPosition == 1 and BarsSinceEntry > 0  And EMAFast00[2] >= MASlow00[2] And EMAFast00[1] < MASlow00[1])

       {

           Sell(FundPositionLots, Open);

       }

   

       If(MarketPosition <> -1 And Data2.MAFast2[1] < Data2.MASlow2[1] And Data1.EMAFast01[2] > Data1.MASlow01[2] And Data1.EMAFast01[1] < Data1.MASlow01[1])

       {

           FundPositionLots = 2 * MinPositionLots;

           SellShort(FundPositionLots, Open);

       }

   

       If(MarketPosition <> -1 And Data2.MAFast2[1] > Data2.MASlow2[1] And Data1.EMAFast01[2] > Data1.MASlow01[2] And Data1.EMAFast01[1] <= Data1.MASlow01[1])

       {

           FundPositionLots = MinPositionLots;

           SellShort(FundPositionLots, Open);

       }

   

       If(MarketPosition <> -1 And Data2.MAFast2[1] < Data2.MASlow2[1] And EMAFast00[2] > MASlow00[2] And EMAFast00[1] < MASlow00[1] And Data1.EMAFast01[1] <= Data1.MASlow01[1])

       {

           FundPositionLots = 2 * MinPositionLots;

           SellShort(FundPositionLots, Open);

       }

   

       If(MarketPosition <> -1 And Data2.MAFast2[1] > Data2.MASlow2[1] And EMAFast00[2] > MASlow00[2] And EMAFast00[1] < MASlow00[1] And Data1.EMAFast01[1] <= Data1.MASlow01[1])

       {

           FundPositionLots = MinPositionLots;

           SellShort(FundPositionLots, Open);

       }

   

       If(MarketPosition == -1 and BarsSinceEntry > 0 And Data1.EMAFast01[2] <= Data1.MASlow01[2] And Data1.EMAFast01[1] > Data1.MASlow01[1])

       {

           BuyToCover(FundPositionLots, Open);

       }

   }

//------------------------------------------------------------------------

// 编译版本    2025/11/7 154009

// 版权所有    winter110

// 更改声明    TradeBlazer Software保留对TradeBlazer平台

//            每一版本的TradeBlazer策略修改和重写的权利

//------------------------------------------------------------------------

//------------------------------------------------------------------------

// 编译版本    2025/11/8 142324

// 版权所有    winter110

// 更改声明    TradeBlazer Software保留对TradeBlazer平台

//            每一版本的TradeBlazer策略修改和重写的权利

//------------------------------------------------------------------------


看了半天没看到你哪里设置图表资金200万了。

楼上发的链接先看一下,怎么设置文档里都说明了。