请问下 为什么简单的 开平仓 系统不执行 要求是9.06开多一手 1450平多 可是回测没有开平仓信号 还有收盘前平仓代码加入后收盘不平仓 以下是源码 //------------------------------------------------------------------------
// 简称: Test_Close_Corrected
// 名称: 极简验证
// 类别: 公式应用
// 类型: 用户应用
// 输出: Void
//------------------------------------------------------------------------
Params
Numeric Lots(1); // 开仓手数
Events
OnInit()
{
SetInitCapital(10000);
SetSlippage(Enum_Rate_PointPerHand, 1);
SetOrderPriceOffset(1);
}
OnBar(ArrayRef<Integer> indexs)
{
Range[0:DataCount()-1]
{
// ========== 1. 计算上一根K线的时间 ==========
// 在回测中,Time 返回的是当前K线的结束时间
// 所以要判断上一根K线的时间 (Time[1])
Numeric LastBarTime = Time[1];
// ========== 2. 开仓逻辑 ==========
// 条件:无持仓,且上一根K线的时间等于开仓时间
If(MarketPosition == 0)
{
// 09:06 和 21:06
If(LastBarTime == 0906 || LastBarTime == 2106)
{
Buy(Lots, Open);
Commentary("开多,开仓价=" + Text(Open));
}
}
// ========== 3. 平仓逻辑 ==========
// 条件:有持仓,且上一根K线的时间等于平仓时间
If(MarketPosition == 1)
{
// 14:50 和 22:50
If(LastBarTime == 1450 || LastBarTime == 2250)
{
Sell(0, Open);
Commentary("尾盘平仓,平仓价=" + Text(Open));
}
}
}
}