请大咖帮忙指正这段代码的错误
ParamsNumeric Length1(5);
Numeric Length2(20);
Numeric Lots(1);
Numeric ATRLength(20);
Numeric TrailStop(2);
Vars
NumericSeries MA1;
NumericSeries MA2;
NumericSeries ATRValue;
NumericSeries HiAfterEntry;
NumericSeries LoAfterEntry;
Numeric Stopline;
BoolSeries bLongStoped(false);
BoolSeries bShortStoped(false);
Begin
ATRValue = AvgTrueRange(ATRLength);
MA1 = AverageFC(Close,Length1);
MA2 = AverageFC(Close,Length2);
PlotNumeric("MA1",MA1);
PlotNumeric("MA2",MA2);
If (!bLongStoped and MarketPosition <> 1 and MA1 > MA2)
{
Buy(Lots,Open);
bShortStoped = false;
}
If (!bShortStoped and MarketPosition <> -1 and MA1 < MA2)
{
SellShort(lots,Open);
SellShort(lots,Open);
}
If (bLongStoped and MarketPosition <> 1 and High >= HiAfterEntry)
{
Buy(Lots, Max(Open, HiAfterEntry));
bShortStoped = false;
}
If (MarketPosition == 1 and BarsSinceEntry == 0) HiAfterEntry = High;
If (MarketPosition == 1 and BarsSinceEntry >= 1)
HiAfterEntry = Max(HiAfterEntry,High);
If (MarketPosition == -1 and BarsSinceEntry == 0) LoAfterEntry = Low;
If (MarketPosition == -1 and BarsSinceEntry >= 1)
LoAfterEntry = Min(LoAfterEntry,Low);
if (BarssinceEntry > 0 and MarketPosition == 1)
{
StopLine = HiAfterEntry - TrailStop * ATRValue;
If (Low <= StopLine)
{
Sell(0, Min(Open, Stopline));
bLongStoped = true;
}
} Else If(BarsSinceEntry > 0 and MarketPosition == -1)
{
StopLine = LoAfterEntry + TrailStop * ATRValue;
If(High >= StopLine)
{
BuyToCover(0, Max(Open, Stopline));
bShortStoped = true;
}
}
End
页:
[1]