哪位老师帮忙改一下不知道哪里出问题了

Params

Numeric SLPercent(3); // 止损百分比

Numeric TPPercent(6); // 目标利润百分比

Numeric ReservePercent(80); // 预留百分比


Numeric MA_Length(20); // 均线长度

Numeric CCI_Period(14); // CCI指标周期

Numeric TrailSLBars(3); // 止损跟踪Bar数

Vars

Series <Numeric> AvgClose;

Series <Numeric> CCI_Value;

Numeric StopLossPrice;

Numeric TargetPrice;

Numeric EntryPrice;



Events

onBar(ArrayRef<Integer> indexs)

{


// 计算指标值

AvgClose = AverageFC(Close, MA_Length);

CCI_Value = CCI(CCI_Period);


   // 多单开仓

   if (MarketPosition == 0 and AvgClose[1] > AvgClose[2] and CCI_Value[1] > 100 and CCI_Value[2] <= 100) {

       EntryPrice = Open[1];

       StopLossPrice = EntryPrice * (1 - SLPercent/100);

       TargetPrice = EntryPrice * (1 + TPPercent/100);

       

       buy(1, Open);

   }

   

   // 空单开仓

   if (MarketPosition == 0 and AvgClose[1] < AvgClose[2] and CCI_Value[1] < -100 and CCI_Value[2] >= -100) {

       EntryPrice = Open[1];

       StopLossPrice = EntryPrice * (1 + SLPercent/100);

       TargetPrice = EntryPrice * (1 - TPPercent/100);

       

       sellShort(1, Open);

   }

   

   // 止损跟踪

   if (MarketPosition == 1 and Close[1] < StopLossPrice) {

       StopLossPrice = Close[1];

   }

   else if (MarketPosition == -1 and Close[1] > StopLossPrice) {

       StopLossPrice = Close[1];

   }

   

   // 平仓

   if (MarketPosition == 1 and Low[1] <= StopLossPrice) {

       sell(1, StopLossPrice);

   }

   else if (MarketPosition == 1 and High[1] >= TargetPrice) {

       sell(1, TargetPrice);

   }

   else if (MarketPosition == -1 and High[1] >= StopLossPrice) {

       buyToCover(1, StopLossPrice);

   }

   else if (MarketPosition == -1 and Low[1] <= TargetPrice) {

       buyToCover(1, TargetPrice);

   }

}


哪位老师帮忙看一下
老师改一下
这段代码哪里逻辑不对吗?哪位老师帮忙看看
代码报错,请老师帮忙看一下
求大神帮忙看看哪里出问题了
哪位大神老师帮我看看哪里不对
不知道哪里错了?
求老师帮忙指点一下
请帮忙改一下代码
请老师改一个条件语句