错误显示缺少分号?加上后还是显示缺少分号,这句话好像不需要分好号呀
Params Numeric FastLength(5); //短周期 Numeric SlowLength(600); //长周期 Numeric money(1); //固定资金开仓:单位万 Vars Series<Numeric> AvgValue1; Series<Numeric> AvgValue2; Numeric myprice; //委托价格 Numeric lots; //委托数量 Numeric TotalEquity; // 按最新收盘价计算出的总资产 Numeric MinPoint; // 一个最小变动单位,也就是一跳 Numeric MyEntryPrice; // 开仓价格,例中为开仓均价,可设置为某次入场价 Numeric TakeProfitSet(30); // 止赢设置 Numeric StopLossSet(20); // 止损设置 Numeric MyExitPrice; // 平仓价格 Events OnInit() { //=========除权换月相关设置============== AddDataFlag(Enum_Data_RolloverBackWard()); //设置后复权 AddDataFlag(Enum_Data_RolloverRealPrice()); //设置映射真实价格 AddDataFlag(Enum_Data_AutoSwapPosition()); //设置自动换仓 AddDataFlag(Enum_Data_IgnoreSwapSignalCalc()); //设置忽略换仓信号计算 //=========交易相关设置============== SetInitCapital(10000); //设置初始资金为 1 万 SetCommissionRate(BitOr(Enum_Rate_FreeOfExitToday,Enum_Rate_ByFillAmount),5); //设置手续费率为成交金额的 5%%,不收平今, BitOr 进行位或运算即设置属性和 SetSlippage(Enum_Rate_PointPerHand,2); //设置滑点为 2 跳/手 myprice=Open/rollover; //这里使用 open/rollover,更为精确的是使用委托价格. Rollvoer 是系统提供的复权系数,真实价格= 后复权的价格/rollover。 TotalEquity = Portfolio_CurrentCapital() + Portfolio_UsedMargin(); lots=IntPart(TotalEquity*0.03/myprice*0.1); //计算开仓手数 IntPart舍入后取整, } OnBar(ArrayRef<Integer> indexs) { AvgValue1=AverageFC(Close,FastLength); AvgValue2=AverageFC(Close,SlowLength); PlotNumeric("MA1",AvgValue1); PlotNumeric("MA2",AvgValue2); If(MarketPosition<>1 And AvgValue1[1]>AvgValue2[1]) { Buy(lots,myprice); } If(MarketPosition <>-1 && AvgValue1[1] < AvgValue2[1]) { SellShort(lots,myprice); } MyEntryPrice=myprice If( MarketPosition == 1 And BarsSinceEntry >= 1) ; // 有多仓的情况 { If(High >= MyEntryPrice + TakeProfitSet*MinPoint) // 止赢条件表达式 { MyExitPrice = MyEntryPrice + TakeProfitSet*MinPoint; // 如果该Bar开盘价即跳空触发,用开盘价代替 If(Open > MyExitPrice) MyExitPrice = Open; Sell(lots,MyExitPrice); } Else If(Low <= MyEntryPrice - StopLossSet*MinPoint) // 止损条件表达式 { MyExitPrice = MyEntryPrice - StopLossSet*MinPoint; // 如果该Bar开盘价即跳空触发,则用开盘价代替 If(Open < MyExitPrice) MyExitPrice = Open; Sell(lots,MyExitPrice); } } Else If(MarketPosition == -1 And BarsSinceEntry >= 1) // 有空仓的情况 { If(Low <= MyEntryPrice - TakeProfitSet*MinPoint) // 止赢条件表达式 { MyExitPrice = MyEntryPrice - TakeProfitSet*MinPoint; If(Open < MyExitPrice) MyExitPrice = Open; BuyToCover(0,MyExitPrice); } Else If(High >= MyEntryPrice + StopLossSet*MinPoint) // 止损条件表达式 { MyExitPrice = MyEntryPrice + StopLossSet*MinPoint; If(Open > MyExitPrice) MyExitPrice = Open; BuyToCover(0,MyExitPrice); } } }