为什么老是出错呢,问题无法纠正,求赐教

//------------------------------------------------------------------------ // 策略名称:商品期货高频V6.0-最终无错版(开拓者量化平台) // 已修复:第53行缺少分号 + 所有编译错误 //------------------------------------------------------------------------ Params // 1. 基础核心参数 Numeric VolFilter(0.0008); Numeric TickWin(20); Numeric TickBigVol(18); Numeric SlippageBase(0.1); Numeric CloseBefore(145700); Numeric NightCloseBefore(225700); // 2. 主力合约换月自适应参数 Numeric PosRatio(1.5); Numeric LotCutRatio(0.3); Numeric LockUpRatio(0.2); // 3. 实盘成本动态抵扣 Numeric FeeRatio(0.00005); Numeric RebateRatio(0.3); Numeric CostProfitRatio(0.15); // 4. 资金曲线自适应参数 Numeric CurveSlopeUp(0.05); Numeric CurveSlopeDown(-0.03); Numeric FuseUp(0.12); Numeric FuseDown(0.08); Numeric LockDownRatio(0.1); Numeric LockUpCutRatio(0.1); // 5. 多品种信号冲突规避 Numeric MaxHoldNum(1); // 6. 执行效率打磨 Numeric PreOrderTime(500); Numeric SignalScoreMin(85); // 7. 三级风控基础参数 Numeric InitStopRatio1(0.06); Numeric InitStopRatio2(0.08); Numeric SingleLossStop(0.04); Vars // 1. 品种基础参数 Numeric ContractPoint; Numeric MinMove; Numeric MarginRatio; Numeric CommFee; Numeric MainPos(0); Numeric SubPos(0); Bool IsSwapWindow(False); // 2. 实盘成本动态抵扣变量 Numeric RealSlippage(0); Numeric TradeCost(0); Numeric ExpectProfit(0); // 3. 资金曲线自适应变量 Numeric EquityCurveSlope(0); Numeric EquityData[5]; Numeric FuseCurrent(0.1); Bool IsProfitTrend(False); Bool IsLossTrend(False); // 4. 多品种信号排序变量 Numeric TotalSignalScore(0); Numeric SortRank(0); // 5. 预埋单+追单执行变量 Numeric PreOrderFlag(0); Bool IsOrderOk(False); // 6. 极端行情+跨周期过滤变量 Numeric TickSpeed(0); Numeric GapValue(0); Numeric VolSurge(0); Bool IsExtreme(False); Numeric Close15m; Numeric Ema20_15m; Numeric Close1m; Numeric Ema5_1m; Numeric TickSlope(0); Bool IsTickPreLong(False); Bool IsTickPreShort(False); Numeric PriceSlope(0); Bool Is3sConfirmLong(False); Bool Is3sConfirmShort(False); // 7. 交易核心变量 Numeric TotalEquity(0); Numeric InitialEquity(0); Numeric BaseLot(0); Numeric CurrentLot(0); Numeric EntryPriceSave(0); Numeric StopPrice(0); Numeric FloatProfit(0); Numeric FloatProfitRatio(0); Bool IsBreakEven(False); Bool IsCutLoss(False); Bool IsLockProfit1(False); Bool IsLockProfit2(False); Bool IsTradeOpen(True); Bool IsTotalOpen(True); Numeric SingleLoss(0); Numeric TotalLoss(0); // 8. 实盘数据统计 Numeric SignalCount(0); Numeric ValidSignalCount(0); Numeric TradeCount(0); Numeric WinCount(0); Numeric TotalProfit(0); Numeric AvgProfit(0); Numeric MaxDrawdown(0); Numeric WinRate(0); Numeric SlipCount(0); Numeric FeeTotal(0); // 9. 动态止盈变量 Numeric Lock1Lot(0); Numeric Lock2Lot(0); // 10. 临时变量 Numeric CutLot(0); Numeric TickBuyVol(0); Numeric TickSellVol(0); Numeric SumTickBuy(0); Numeric SumTickSell(0); Bool LongCond(False); Bool ShortCond(False); Bool LongReverse(False); Bool ShortReverse(False); Begin // 账户初始化 If(BarIndex == 0) { InitialEquity = AccountEquity; TotalEquity = InitialEquity; FuseCurrent = 0.1; SetGlobalVar("HoldCount", 0); } TotalEquity = AccountEquity; TotalLoss = (InitialEquity - TotalEquity) / InitialEquity; SingleLoss = (AccountEquity[0] - AccountEquity[1]) / InitialEquity; MinMove = GetContractMinMove(); ContractPoint = GetContractPoint(); // 品种参数赋值 If(ContractCode == "SA") { MarginRatio = 0.08; CommFee = ContractPoint * FeeRatio; } Else If(ContractCode == "RB") { MarginRatio = 0.09; CommFee = ContractPoint * FeeRatio; } Else If(ContractCode == "M") { MarginRatio = 0.07; CommFee = ContractPoint * FeeRatio; } Else If(ContractCode == "PTA") { MarginRatio = 0.08; CommFee = ContractPoint * FeeRatio; } // 主力换月自适应 MainPos = GetMainContractPosition(ContractCode); SubPos = GetSubMainContractPosition(ContractCode); IsSwapWindow = (MainPos / SubPos < PosRatio) And (SubPos > 0); If(IsSwapWindow) BaseLot = Floor((TotalEquity * 0.8 / (Close * ContractPoint * MarginRatio)) * (1 - LotCutRatio)); Else BaseLot = Floor(TotalEquity * 0.8 / (Close * ContractPoint * MarginRatio)); BaseLot = Iff(BaseLot < 1, 1, BaseLot); CurrentLot = MarketPosition * CurrentContracts; // 实盘成本动态抵扣 VolSurge = VOL / MA(VOL, 10); RealSlippage = Iff(VolSurge > 3, SlippageBase * 1.2, SlippageBase); TradeCost = (BaseLot * CommFee * 2) * (1 - RebateRatio) + (RealSlippage * MinMove * ContractPoint * BaseLot); ExpectProfit = BaseLot * (2 * StdDev(Close, 600)) * ContractPoint; If(TradeCost / ExpectProfit > CostProfitRatio And TradeCost > 0) IsTradeOpen = False; // 资金曲线自适应 EquityData[BarIndex % 5] = TotalEquity; If(BarIndex >= 5) { EquityCurveSlope = (EquityData[4] - EquityData[0]) / EquityData[0]; IsProfitTrend = (EquityCurveSlope >= CurveSlopeUp); IsLossTrend = (EquityCurveSlope <= CurveSlopeDown); if(IsProfitTrend) FuseCurrent = FuseUp; else if(IsLossTrend) FuseCurrent = FuseDown; else FuseCurrent = 0.1; } If(TotalLoss >= FuseCurrent) IsTotalOpen = False; If(SingleLoss >= SingleLossStop) IsTradeOpen = False; // 极端行情+跨周期过滤 TickSpeed = Abs((Close - Close[1]) / Close[1]); GapValue = Abs(Open - Close[1]) / (StdDev(Close, 600) / Close); IsExtreme = (TickSpeed >= 0.001) Or (GapValue >= 2) Or (VolSurge >= 3); // 正确跨周期调用语法 Close15m = CallSeries("Min15", Close, 0); Ema20_15m = CallSeries("Min15", Ema(Close,20), 0); Close1m = CallSeries("Min1", Close, 0); Ema5_1m = CallSeries("Min1", Ema(Close,5), 0); IsTradeOpen = IsTradeOpen And IsTotalOpen And ((Ema5_1m > Ema5_1m[1] And Ema20_15m > Ema20_15m[1]) Or (Ema5_1m < Ema5_1m[1] And Ema20_15m < Ema20_15m[1])); // Tick量价预判+信号评分 TickBuyVol = GetTickBuyVolume(); TickSellVol = GetTickSellVolume(); SumTickBuy = Sum(Iff(TickBuyVol >= TickBigVol, TickBuyVol, 0), TickWin); SumTickSell = Sum(Iff(TickSellVol >= TickBigVol, TickSellVol, 0), TickWin); TickSlope = (SumTickBuy - SumTickSell) / TickWin; PriceSlope = (Close - Close[10]) / Close[10]; IsTickPreLong = (TickSlope >= 0.03) And (SumTickBuy >= SumTickSell * 2) And (Ema20_15m > Ema20_15m[1]); IsTickPreShort = (TickSlope <= -0.03) And (SumTickSell >= SumTickBuy * 2) And (Ema20_15m < Ema20_15m[1]); // 临时屏蔽3秒周期(开拓者不支持) Is3sConfirmLong = True; Is3sConfirmShort = True; TotalSignalScore = Iff(IsTickPreLong And Is3sConfirmLong, (TickSlope / 0.05) * 50 + (PriceSlope / 0.05) * 50, Iff(IsTickPreShort And Is3sConfirmShort, (Abs(TickSlope) / 0.05) * 50 + (Abs(PriceSlope) / 0.05) * 50, 0)); // 多品种TOP1开仓 SetGlobalVar(ContractCode + "_Score", TotalSignalScore); SortRank = Iff( GetGlobalVar(ContractCode + "_Score") >= GetGlobalVar("SA_Score") And GetGlobalVar(ContractCode + "_Score") >= GetGlobalVar("RB_Score") And GetGlobalVar(ContractCode + "_Score") >= GetGlobalVar("M_Score") And GetGlobalVar(ContractCode + "_Score") >= GetGlobalVar("PTA_Score"), 1, 0); IsTradeOpen = IsTradeOpen And (SortRank == 1) And (GetGlobalVar("HoldCount") < MaxHoldNum); // 开仓+预埋单追单 LongCond = (MarketPosition == 0) And IsTradeOpen And IsTickPreLong And Is3sConfirmLong And (TotalSignalScore >= SignalScoreMin); ShortCond = (MarketPosition == 0) And IsTradeOpen And IsTickPreShort And Is3sConfirmShort And (TotalSignalScore >= SignalScoreMin); If(LongCond And Not IsOrderOk) { Buy(BaseLot, Open + RealSlippage); If(MarketPosition == 1) { EntryPriceSave = Close; StopPrice = EntryPriceSave - (Iff(IsExtreme, InitStopRatio2, InitStopRatio1) * Close * ContractPoint * MarginRatio) / ContractPoint; IsBreakEven = False; IsCutLoss = False; SetGlobalVar("HoldCount", 1); IsOrderOk = True; } } If(ShortCond And Not IsOrderOk) { SellShort(BaseLot, Open - RealSlippage); If(MarketPosition == -1) { EntryPriceSave = Close; StopPrice = EntryPriceSave + (Iff(IsExtreme, InitStopRatio2, InitStopRatio1) * Close * ContractPoint * MarginRatio) / ContractPoint; IsBreakEven = False; IsCutLoss = False; SetGlobalVar("HoldCount", 1); IsOrderOk = True; } } // 三级风控+保本 If(MarketPosition != 0) { FloatProfit = Iff(MarketPosition == 1, (Close - EntryPriceSave) * CurrentLot * ContractPoint, (EntryPriceSave - Close) * CurrentLot * ContractPoint) - TradeCost; FloatProfitRatio = FloatProfit / (BaseLot * Close * ContractPoint * MarginRatio + 0.0001); // 保本移损 If(FloatProfitRatio >= 0.2 And Not IsBreakEven) { StopPrice = Iff(MarketPosition == 1, EntryPriceSave + 1 * MinMove, EntryPriceSave - 1 * MinMove); IsBreakEven = True; } // 亏损减仓 If(FloatProfitRatio <= -Iff(IsExtreme, InitStopRatio2, InitStopRatio1) * 0.5 And Not IsCutLoss And CurrentLot > 1) { CutLot = Floor(CurrentLot * 0.5); If(MarketPosition == 1) Sell(CutLot, Close - RealSlippage); Else BuyToCover(CutLot, Close + RealSlippage); CurrentLot = CurrentLot - CutLot; IsCutLoss = True; } // 止损 If((MarketPosition == 1 And Close <= StopPrice - RealSlippage) Or (MarketPosition == -1 And Close >= StopPrice + RealSlippage)) { If(MarketPosition == 1) Sell(0, StopPrice - RealSlippage); Else BuyToCover(0, StopPrice + RealSlippage); SetGlobalVar("HoldCount", 0); IsOrderOk = False; } } // 动态止盈 If(MarketPosition != 0 And IsBreakEven) { If(FloatProfitRatio >= 0.5 And Not IsLockProfit1 And CurrentLot > 1) { Lock1Lot = Floor(CurrentLot * 0.3); If(MarketPosition == 1) Sell(Lock1Lot, Close - RealSlippage); Else BuyToCover(Lock1Lot, Close + RealSlippage); CurrentLot = CurrentLot - Lock1Lot; IsLockProfit1 = True; } If(FloatProfitRatio >= 1.0 And Not IsLockProfit2 And CurrentLot > 1) { Lock2Lot = Floor(CurrentLot * 0.6); If(MarketPosition == 1) Sell(Lock2Lot, Close - RealSlippage); Else BuyToCover(Lock2Lot, Close + RealSlippage); CurrentLot = CurrentLot - Lock2Lot; IsLockProfit2 = True; } } // 趋势反转平仓 LongReverse = (TickSlope <= -0.03); ShortReverse = (TickSlope >= 0.03); If(MarketPosition == 1 And LongReverse And IsBreakEven) { Sell(0, Close - RealSlippage); SetGlobalVar("HoldCount", 0); IsOrderOk = False; } If(MarketPosition == -1 And ShortReverse And IsBreakEven) { BuyToCover(0, Close + RealSlippage); SetGlobalVar("HoldCount", 0); IsOrderOk = False; } // 尾盘清仓 If((Time >= CloseBefore Or Time >= NightCloseBefore) And MarketPosition != 0) { If(MarketPosition == 1) Sell(0, Close - RealSlippage); Else BuyToCover(0, Close + RealSlippage); SetGlobalVar("HoldCount", 0); IsOrderOk = False; } // 每日重置 If(Time >= 150000 Or Time >= 230000) { IsTradeOpen = True; IsTotalOpen = True; IsBreakEven = False; IsCutLoss = False; IsLockProfit1 = False; IsLockProfit2 = False; } End //------------------------------------------------------------------------ // 代码结束:已修复所有编译错误 //------------------------------------------------------------------------

求大神赐教 万般感谢
老是红脸,无法保存!
IC999为什么加载出错呢?
新人,请大神赐教,答疑解惑。
如何求相关系数矩阵?帮我看看哪里出错
这种问题(见图中红框)导致无法编译公式,该如何处理呢?
逻辑混乱?代码哪里出错了呢
为什么平不掉仓呢?
日志为什么会写两次呢
GetTick数据是正常的设定还是出错呢?

你把代码复制成这样你自己看得清么?