帮我看下这段代码
原本是在仓位等于0或者1的时候才开仓的,但是运行了发现不停开仓 ,根本不手0或1的影响?ParamsNumeric BH(60);Numeric dh(40); Numeric lot(0); Numeric FastLen(60); // 分钟线 Numeric SlowLen(30); //分钟 Numeric NomLen(20); //日线 Numeric NomL(10); //10日高低点 Numeric Ch(5); //前多少根日线 Numeric Length(100); //多少根分钟线 Numeric signbuy(0); Numeric signsell(0); Numeric ReBar(200); Varsseries<Numeric> MinPoint(0); // 声明变量MinPoint,一个最小变动单位,也就是一跳。Numeric MyEntryPrice(0); // 声明变量MyEntryPrice,英文好的,看英文意思都知道的,开仓价格,本例是开仓均价,也可根据需要设置为某次入场的价格。 Series<Numeric> FastMA; // 快速均线 Series<Numeric> SlowMA; // 慢速均线 Numeric NomMA; Series<Numeric> x(0); Series<Numeric> sig(1); Series<Numeric> tt; Series<Numeric> ReEntryCount; // 跟踪止损后记录BAR序号 Numeric MyExitPrice; // 声明变量MyExitPrice,平仓价格。 Series<Numeric> ATR; Series<Numeric> StopPri; //跟踪止损价 Series<Numeric> StopLPri; Series<Numeric> stopwin; Series<Numeric> HighValue; //多头进场之后的盈利峰值价 Series<Numeric> AF; Series<Numeric> xx(0); Series<Numeric> xy(0); //跟踪Acceleration Series<Numeric> HighestAfterEntry; //声明序列变量HighestAfterEntry,开仓后出现的最高价。Series<Numeric> LowestAfterEntry; //声明序列变量LowestAfterEntry,开仓后出现的最低价。 Numeric StopPrice(0); Series<Bool> Condition1(False);series<Bool> Yun(False); series<bool> condition(true);series<bool> conditiona(true); Numeric StopATR;Series<Numeric> HH; Numeric HHH; // 最近N根BAR的高点 Series<Numeric> LL; Numeric PP; Global Numeric h1; Global Numeric h2; Global Numeric L2;Global Numeric l1; // 最近N根BAR的低 Numeric DDH; Numeric Bigbar; Numeric CL; Series<Numeric> PPP; Series<Numeric> LD; Series<Numeric> H1d; Series<Numeric> H2d; Series<Numeric> L1d; Series<Numeric> L2d;Series<Numeric> op; Series<Numeric> HD; Series<Numeric> lld; Series<Numeric> hhd; Series<Bool> shang; //锤子线阳 Series<Bool> xia;// 吊头线阴// Series<Bool> Condition1; // 条件1// Series<Bool> Condition2; // 条件2 Numeric MyRange; //K线幅度EventsOnInit(){ Array<Numeric> timepoint; timepoint[0] = 0.145950; SetTriggerBarClose(timepoint);}OnBar(ArrayRef<Integer> indexs) { range[0:0] {HD=Highest(high[1],dh); LD=Lowest(Low[1],dh); H2d=Highest(high[1],BH); L2D=Lowest(Low[1],BH); MinPoint = MinMove*PriceScale;//固定的最小跳动价公式。 HH=max(open,AvgEntryPrice-2*minpoint); ll=min(open,AvgEntryPrice+2*minpoint); Commentary("data1.h1d="+Text(data1.h1d)); Commentary("BarsSinceExit="+Text(BarsSinceExit)); Commentary("2*MinPoint="+Text(2*MinPoint)); Commentary("L1="+Text(L1)); Commentary("H1="+Text(H1)); SlowMA = Average(Close,SlowLen); FastMA = Average(Close, FastLen); PlotNumeric("FastMA",FastMA); PlotNumeric("SlowMA",SlowMA); } if( (MarketPosition ==0) and High >HD ){ Buy(0,max(hd,open)); L1=LOW; xx=1; } if (BarsSinceEntry>0 and MarketPosition ==1 and low<l1) { Sell(0,l1); } } // 开仓/ OnBarClose(ArrayRef<Integer> indexs) { if (MarketPosition ==1 and close>high[1]) { Buy(0,close); } if (BarsSinceEntry>0 and MarketPosition ==1 and Low<FastMA) { Sell(0,close); } }