老师可以帮我修复一下吗?
//------------------------------------------------------------------------// 名称: 量大入场,量小出场-正向开仓策略(TBQuant3版)//------------------------------------------------------------------------Params Integer volLen(20); // 成交量均线周期 Numeric highVolMult(2.0); // 高量阈值倍数(入场) Numeric lowVolMult(0.5); // 低量阈值倍数(平仓) Integer atrLen(14); // ATR周期 Numeric slMult(1.0); // 止损倍数 Numeric tpMult(2.5); // 止盈倍数 Numeric qty(1); // 手数Vars Numeric volAvg, atrValue; Numeric longStop, longTP, shortStop, shortTP; Bool highVolCondition, lowVolCondition; Bool signalLong, signalShort;//-------------------------------// 1. 成交量计算//-------------------------------volAvg = Average(Volume, volLen);highVolCondition = Volume >= volAvg * highVolMult;lowVolCondition = Volume <= volAvg * lowVolMult;//-------------------------------// 2. ATR止盈止损计算//-------------------------------atrValue = AvgTrueRange(atrLen);longStop = Close - atrValue * slMult;longTP = Close + atrValue * tpMult;shortStop = Close + atrValue * slMult;shortTP = Close - atrValue * tpMult;//-------------------------------// 3. 信号定义//-------------------------------signalLong = Close > Average(Close, volLen) and highVolCondition;signalShort = Close < Average(Close, volLen) and highVolCondition;//-------------------------------// 4. 平仓逻辑//-------------------------------if lowVolCondition thenbegin if MarketPosition = 1 then Sell("ExitLong") Next Bar at Market; if MarketPosition = -1 then BuyToCover("ExitShort") Next Bar at Market;end;//-------------------------------// 5. 开仓逻辑(禁止双向)//-------------------------------if MarketPosition <= 0 and signalLong thenbegin if MarketPosition = -1 then BuyToCover("CloseShort") Next Bar at Market; Buy("OpenLong") qty shares Next Bar at Market;end;if MarketPosition >= 0 and signalShort thenbegin if MarketPosition = 1 then Sell("CloseLong") Next Bar at Market; SellShort("OpenShort") qty shares Next Bar at Market;end;//-------------------------------// 6. 止盈止损(动态判断)//-------------------------------if MarketPosition = 1 thenbegin if Low <= longStop then Sell("LongStop") Next Bar at Market; if High >= longTP then Sell("LongTP") Next Bar at Market;end;if MarketPosition = -1 thenbegin if High >= shortStop then BuyToCover("ShortStop") Next Bar at Market; if Low <= shortTP then BuyToCover("ShortTP") Next Bar at Market;end;📊 策略逻辑说明(量大入场,量小出场)一、核心思路成交量大 → 开仓成交量小 → 平仓方向判断:用价格相对均线位置决定多空方向二、具体逻辑模块逻辑说明成交量条件当前成交量 ≥ 均量 × 高倍数 → 触发入场; ≤ 均量 × 低倍数 → 触发出场趋势方向close > 均线 → 多头; close < 均线 → 空头止盈止损使用 ATR 动态止盈止损,分别为 2.5×ATR、1×ATR仓位控制禁止双向开仓,开仓前自动平掉反向仓开多条件成交量高 + 收盘价 > 均线开空条件成交量高 + 收盘价 < 均线平仓条件成交量低(多空一致)三、参数可调参数默认值作用volLen20成交量均线周期highVolMult2.0高成交量阈值倍数lowVolMult0.5低成交量阈值倍数atrLen14ATR周期slMult1.0止损倍数tpMult2.5止盈倍数