- 精华
- 0
- 在线时间
- 6 小时
- UID
- 149608
- 积分
- 2
- 帖子
- 1
- 阅读权限
- 10
- 注册时间
- 2012-12-26
- 最后登录
- 2024-2-18
- 精华
- 0
- UID
- 149608
- 积分
- 2
- 帖子
- 1
- 主题
- 1
- 阅读权限
- 10
- 注册时间
- 2012-12-26
- 最后登录
- 2024-2-18
|
本帖最后由 q54900035 于 2020-2-22 18:37 编辑
我写了一个简单的均线突破开仓策略,赚十个点止盈,但是运行以后发现止盈止损的策略无效,出场信号一律是第三天的最低价,不知道问题出在哪里,请大佬帮我看一下,谢谢了。
Params
Numeric length1(10);
Numeric length2(30);
Numeric boLength(10);
Vars
NumericSeries ma1;
NumericSeries DonchianHi;
NumericSeries DonchianLo;
Numeric MyEnterPrice;
NumericSeries ma2;
Numeric MinPoint;
Numeric zhisun;
Numeric zhiying;
Numeric MyExitPrice;
Begin
MinPoint = MinMove*PriceScale;
DonchianHi = HighestFC(High[1],boLength);
DonchianLo = LowestFC(Low[1],boLength);
ma1=Average(Close,length1);
ma2=Average(Close,length2);
if(MarketPosition ==0 and ma1[1]>ma2[1] and high>DonchianHi )
{
MyEnterPrice=DonchianHi;
zhiying=MyEnterPrice+10;
zhisun=DonchianLo;
Buy(1,MyEnterPrice);
}
if(MarketPosition ==1 and BarsSinceEntry>1 and high>zhiying)
{
MyExitPrice=zhiying;
Sell(1,MyExitPrice);
}
if(MarketPosition ==1 and BarsSinceEntry>1 and l<zhisun)
{
MyExitPrice=zhisun;
Sell(1,MyExitPrice);
}
PlotNumeric("均线1",ma1);
PlotNumeric("均线2",ma2);
End
|
|