自适应均线
这个自适应均线程序哪里有问题,请老师改写一下,谢谢Params Series<Numeric> Price(1); //数值型序列值 Numeric EffRatioLength(10); //自适应周期数 Numeric FastAvgLength(2); //短周期数 Numeric SlowAvgLength(30); //长周期数//系统相关Numeric ConfirmPeriod(3); //确认均线趋势次数 Numeric StdMultiplier(1); //过滤器百分比//交易相关Numeric Slipes(2); //滑点Vars//AMA相关Numeric STDLen(0); //标准差长度Numeric PriceSTD(0);Numeric STDRatio(1); //进入标准差的倍数Bool LongIndicator(True);Bool ShortIndicator(True);Numeric i;Numeric NetChg(0); Numeric TotChg(0); Numeric EffRatio(0); Numeric ScaledSFSqr(0); Series<Numeric> AMAValue; Numeric SFDiff;EventsOnBar(ArrayRef<Integer> indexs){ if(CurrentBar == 0) { AMAValue = Price; }Else { NetChg = Abs( Price - Price[EffRatioLength] ); TotChg = Summation( Abs( Price - Price[1] ), EffRatioLength ); EffRatio = IIF(TotChg > 0, NetChg / TotChg, 0); SFDiff = 2 / ( FastAvgLength + 1 ) - 2 / ( SlowAvgLength + 1 ); ScaledSFSqr = Sqr( 2 / ( SlowAvgLength + 1 ) + EffRatio * SFDiff ); AMAValue = AMAValue[1] + ScaledSFSqr * ( Price - AMAValue[1] ); } STDLen=SlowAvgLength; PriceSTD=StandardDev(Close[1],STDLen);//当不持多仓的情况下,如果做多条件满足,则做多 If(MarketPosition <>1 && AMAValue[1]-Lowest(AMAValue[1],ConfirmPeriod) > PriceSTD*STDRatio*StdMultiplier/100 ) { Buy(0,Open+Slipes); PlotString ("top","jdc",Portfolio_TotalProfit,Red); }//当不持空仓的情况下,如果做空条件满足,则做空 If(MarketPosition <>-1 && Highest(AMAValue[1],ConfirmPeriod)-AMAValue[1] > PriceSTD*STDRatio*StdMultiplier/100 ) { SellShort(0,Open-Slipes); PlotString ("top","jkc",Portfolio_TotalProfit,Red); } PlotNumeric("PL",Portfolio_TotalProfit);}