请帮忙修改,提示错误

//------------------------------------------------------------------------ // 简称: aberplus // 名称: 多均线轨道交易多层止损止盈 // 类别: 公式应用 // 类型: 用户应用 // 输出: Void //------------------------------------------------------------------------ Params Numeric Length(80); Numeric lots(0); Vars Numeric AvgOut(0); Numeric AvgOut2(0); Numeric AvgOut3(0); Numeric AvgOut4(0); Numeric AvgOut5(0); Numeric myvolav(0); Numeric Ips(0); Numeric sps(0); Numeric ps(0); Numeric crit(0); Numeric leprice(0); Numeric seprice(0); Numeric sigma (0); // 均线指标计算 AvgOut = Average (Close,Length); AvgOut2 = Average(Close, Length - intpart( Length / 8 ) ); AvgOut3 = Average (Close, Length - intpart( Length / 8 )*2); AvgOut4 = Average (Close, Length - intpart( Length / 8 )* 3 ); AvgOut5 = Average (Close, Length - intpart( Length / 8 ) * 4 ); Sigma=(StandardDev(Close, Length) * 2);//标准差 myvolav = (Sigma + Sigma[1] + Sigma[ 2] ) / 3;//三个标准差均值 lePrice = AvgOut + Sigma ;//上轨 sePrice = AvgOut - Sigma;//下轨 Events //突破一倍标准差,进行建仓。限制条件中,有一条是必须跌回了最长期的均线后才能开仓,即lps==0。 //开多条件 if (MarketPosition < 1 and Close[1] > lePrice[1] and Sigma[1] > myVolav[1] and lps == 0 ) { ps=closer[1] + Sigma[1]; crit= 1; Buy(lots,open); } //开空条件 if (MarketPosition > -1 and Close[1] < sePrice[1] and Sigma[1] > MyVolav[1] and sps==0 ) { SellShort(lots.open); ps=close[1] - sigma[1]; crit= 1. //跌破均线,进行平仓。盈利越多,跌破的均线周期越短 if (MarketPosition ==1 and Close[1] < AvgOut[1] and crit==1) { Sell(0.open): lps=0; } if (MarketPosition ==1 and Close[1] < AvgOut2[1] and crit==2) { Sell(0.open): lps=1; } if (MarketPosition ==1 and Close[1] < AvgOut3[1] and crit==3) { Sell(0.open): lps=1; } if (MarketPosition ==1 and Close[1] < AvgOut4[1] and crit==4) { Sell(0.open): lps=1; } if (MarketPosition ==1 and Close[1] < AvgOut5[1] and crit==5) { Sell(0.open): lps=1; } if (MarketPosition ==1 and crit==6) { Sell(0.open): lps=1; } //更新盈利级别,按照sigma递增 if (MarketPosition ==1 and Close[1]> ps) { crit=crit+1; ps = Close[1]+ Sigma[1]; } if (MarketPosition == -1 and Close[1]< ps) { crit=crit+1; ps = Close[1] - Sigma[1]: } //只有当跌破最长期的均线后,才能准备下一次的开仓 if (sps == 1 and Close[1]> AvgOut[1]) sps=0; if (lps == 1 and Close[1]< AvgOut[1]) lps=0;

我把一眼能见到的错误修改了下,至于公式逻辑,我觉得这个应该是用户自己应该解决的问题。抱歉! Params Numeric Length(80); Numeric lots(0); Vars Series<Numeric> AvgOut(0); Series<Numeric> AvgOut2(0); Series<Numeric> AvgOut3(0); Series<Numeric> AvgOut4(0); Series<Numeric> AvgOut5(0); Series<Numeric> myvolav(0); Series<Numeric> lps(0); Numeric sps(0); Numeric ps(0); Series<Numeric> crit(0); Series<Numeric> leprice(0); Series<Numeric> seprice(0); Series<Numeric> sigma (0); Events OnBar(ArrayRef<Integer> indexs) { // 均线指标计算 AvgOut = Average (Close,Length); AvgOut2 = Average(Close, Length - intpart( Length / 8 ) ); AvgOut3 = Average (Close, Length - intpart( Length / 8 )*2); AvgOut4 = Average (Close, Length - intpart( Length / 8 )* 3 ); AvgOut5 = Average (Close, Length - intpart( Length / 8 ) * 4 ); Sigma=StandardDev(Close, Length) * 2;//标准差 myvolav = (Sigma + Sigma[1] + Sigma[ 2] ) / 3;//三个标准差均值 lePrice = AvgOut + Sigma; //上轨 sePrice = AvgOut - Sigma; //下轨 //突破一倍标准差,进行建仓。限制条件中,有一条是必须跌回了最长期的均线后才能开仓,即lps==0。 //开多条件 if (MarketPosition < 1 and Close[1] > lePrice[1] and Sigma[1] > myVolav[1] and lps == 0 ) { ps=close[1] + Sigma[1]; crit= 1; Buy(lots,open); } //开空条件 if (MarketPosition > -1 and Close[1] < sePrice[1] and Sigma[1] > MyVolav[1] and sps==0 ) { SellShort(lots,open); ps=close[1] - sigma[1]; crit= 1; } //跌破均线,进行平仓。盈利越多,跌破的均线周期越短 if (MarketPosition ==1 and Close[1] < AvgOut[1] and crit==1) { Sell(0,open); lps=0; } if (MarketPosition ==1 and Close[1] < AvgOut2[1] and crit==2) { Sell(0,open); lps=1; } if (MarketPosition ==1 and Close[1] < AvgOut3[1] and crit==3) { Sell(0,open); lps=1; } if (MarketPosition ==1 and Close[1] < AvgOut4[1] and crit==4) { Sell(0,open); lps=1; } if (MarketPosition ==1 and Close[1] < AvgOut5[1] and crit==5) { Sell(0,open); lps=1; } if (MarketPosition ==1 and crit==6) { Sell(0,open); lps=1; } //更新盈利级别,按照sigma递增 if (MarketPosition ==1 and Close[1]> ps) { crit=crit+1; ps = Close[1]+ Sigma[1]; } if (MarketPosition == -1 and Close[1]< ps) { crit=crit+1; ps = Close[1] - Sigma[1]; } //只有当跌破最长期的均线后,才能准备下一次的开仓 if (sps == 1 and Close[1]> AvgOut[1]) sps=0; if (lps == 1 and Close[1]< AvgOut[1]) lps=0; }

不好意思,您这段代码初级错误太多了,建议一定要先学习下基础知识。