通道突破未来函数问题
以下策略有未来函数的情况,麻烦各位老师点拨一下Params Numeric P1(20); Numeric P2(10000);Vars Series<Numeric> UpperBand;// 通道上轨 Series<Numeric> LowerBand;// 通道下轨 Series<Numeric> ATRVal;// ATRVal值 Numeric Lots(0);// 仓位Events OnReady() { } OnBar(ArrayRef<Integer> indexs) { Numeric MinPoint = MinMove * PriceScale;// 最小变动价位 UpperBand = Highest(High[1],P1); LowerBand = Lowest(Low[1],P1); ATRVal = AvgTrueRange(14); PlotNumeric("UpperBand", UpperBand); PlotNumeric("LowerBand", LowerBand); Lots = IntPart(P2/(ATRVal * 3 * ContractUnit() * BigPointValue())); If(MarketPosition == 0) { // 开多 If(High > UpperBand) { Buy(Lots,UpperBand); } // 开空 If(Low < LowerBand) { SellShort(Lots,LowerBand); } } If(MarketPosition > 0) { // 反转平多 If(Low < LowerBand) { Sell(0,LowerBand); Commentary("多单反转平仓:"+Text(LowerBand)); } } If(MarketPosition < 0) { // 反转平空 If(High > UpperBand) { BuyToCover(0,UpperBand); Commentary("空单反转平仓:"+Text(UpperBand)); } } }