跨周期策略问题

//------------------------------------------------------------------------ // 简称: L_CrossCycleDualEmaMa // 名称: 跨周期混合双均线多头策略 // 类别: 策略应用 // 类型: 用户应用 // 输出: Void //------------------------------------------------------------------------ Params Numeric LengthFast0(5);//5分钟短周期参数 Numeric LengthSlow0(20);//5分钟长周期参数 Numeric LengthFast1(5);//日线短周期参数 Numeric LengthSlow1(10);//日线长周期参数 Numeric MinPositionLots(1); Vars Series<Numeric> EMAFast0; Series<Numeric> MASlow0; Series<Numeric> MAFast1; Series<Numeric> MASlow1; 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()); //忽略换仓信号计算 } } OnBar(ArrayRef<Integer> indexs) { EMAFast0 = Average(Close, LengthFast0); MASlow0 = XAverage(Close, LengthSlow0); Data1.MAFast1 = Data1.Average(Data1.Close, LengthFast1); Data1.MASlow1 = Data1.Average(Data1.Close, LengthSlow1); PlotNumeric("EMAFast0",EMAFast0); PlotNumeric("MASlow0",MASlow0); Data1.PlotNumeric("Data1.MAFast1",Data1.MAFast1); Data1.PlotNumeric("Data1.MASlow1",Data1.MASlow1); If(MarketPosition <> 1 And Data1.MAFast1[1] >= Data1.MASlow1[1] And EMAFast0[2] < MASlow0[2] And EMAFast0[2] >= MASlow0[1]) { FundPositionLots = 2 * MinPositionLots; Buy(FundPositionLots, Open); } If(MarketPosition <> 1 And Data1.MAFast1[1] < Data1.MASlow1[1] And EMAFast0[2] < MASlow0[2] And EMAFast0[2] >= MASlow0[1]) { FundPositionLots = MinPositionLots; Buy(FundPositionLots, Open); } If(MarketPosition == 1 And EMAFast0[2] >= MASlow0[2] And EMAFast0[2] < MASlow0[1]) { Sell(FundPositionLots, Open); } } //------------------------------------------------------------------------ // 编译版本 2025/11/6 190428 // 版权所有 winter110 // 更改声明 TradeBlazer Software保留对TradeBlazer平台 // 每一版本的TradeBlazer策略修改和重写的权利 //------------------------------------------------------------------------