请哪位大神给看一下问题出在哪里?
加载后刚开始一切正常,随着不断切换周期逐渐开始死机。Params
Numeric FastLength(5); //短周期参数
Numeric N(2); //止赢跳数
Numeric L(1); //止损跳数
Vars
Numeric MinPoint; //最小变动单位
NumericSeries AvgValue; //移动平均
NumericSeries myEntryPrice; //开仓价格
NumericSeries myLastPrice; //我的最新价
Numeric i; //循环参数
Begin
If(!CallAuctionFilter()) Return; //集合竞价过滤
MinPoint = MinMove*PriceScale;
AvgValue = AverageFC(Close,FastLength);
If(BarStatus == 2&&High >= AvgValue)
{ For i = 0 to 1;
Buy(1,High);
myEntryPrice = High;
myLastPrice = myEntryPrice + N*MinPoint;
i = i+1;
SetGlobalVar(0,myLastPrice);
myLastPrice = GetGlobalVar(0);
If(MarketPosition == 1)
{If( Close >= myLastPrice or Close <= myEntryPrice - L*MinPoint);
{
Sell(1,Close);
}
}
}
While (BarStatus == 2 && High >= myLastPrice + MinPoint)
{ If(MarketPosition == 0 && Close >= myLastPrice)
{ Buy(1, Close);
myEntryPrice = Close;
myLastPrice = myEntryPrice + N*MinPoint;
SetGlobalVar(0, myLastPrice);
}
If(Close >= myLastPrice or Close <= myEntryPrice - L*MinPoint);
{
Sell(1,Close);
}
}
If(BarStatus == 2 && Low <= AvgValue-3*MinPoint)
{ For i = 0 to 1;
SellShort(1,Low);
myEntryPrice = Low;
myLastPrice = myEntryPrice - N*MinPoint;
i = i+1;
SetGlobalVar(1,myLastPrice);
myLastPrice = GetGlobalVar(1);
If(MarketPosition == -1)
{If( Close <= myLastPrice or Close >= myEntryPrice + L*MinPoint);
{
BuyToCover(1,Close);
}
}
}
While (BarStatus == 2 && Low <= myLastPrice - MinPoint)
{ If(MarketPosition == 0 && Close <= myLastPrice)
{ SellShort(1, Close);
myEntryPrice = Close;
myLastPrice = myEntryPrice - N*MinPoint;
SetGlobalVar(1, myLastPrice);
}
If(Close <= myLastPrice or Close >= myEntryPrice + L*MinPoint);
{
BuyToCover(1,Close);
}
}
End
While语句中没有退出机制,容易造成死循环,建议换成If条件句。 本帖最后由 kingwayzxmoni 于 2021-8-31 17:53 编辑
咱们这里多久回复? 两年前还有管理员回复,现在就说不好了
页:
[1]