- 精华
- 0
- 在线时间
- 5 小时
- UID
- 229723
- 积分
- 3
- 帖子
- 3
- 阅读权限
- 10
- 注册时间
- 2016-3-11
- 最后登录
- 2019-4-19
- 精华
- 0
- UID
- 229723
- 积分
- 3
- 帖子
- 3
- 主题
- 0
- 阅读权限
- 10
- 注册时间
- 2016-3-11
- 最后登录
- 2019-4-19
|
Params
//此处添加参数
Numeric shortlength(5);
Numeric longlength(10);
Numeric ATRlength(25);
Vars
//此处添加变量
NumericSeries MAshort;
NumericSeries MAlong;
NumericSeries MAlonger;
NumericSeries highestprice;
NumericSeries ATR;
NumericSeries stopprice;
Begin
//此处添加代码正文
MAshort=AverageFC(Close,shortlength);
MAlong=AverageFC(Close,longlength);
PlotNumeric("5日均线",MAshort);
PlotNumeric("10日均线",MAlong);
ATR=AvgTrueRange(ATRlength);
Commentary(" 3倍波动幅度= "+text(3*ATR));
If(MAshort[1]>MAlong[1] && close[1]> MAlonger[1])
{
Buy(1,Open);
}
If(MarketPosition<>0 && BarsSinceEntry==0) highestprice=high;
If(MarketPosition<>0 && BarsSinceEntry>0) highestprice=max(highestprice,high);
Commentary(" 入场后最高价格= "+text(highestprice));
stopprice=highestprice[1]-3*ATR[1];
Commentary(" 止损价格= "+text(stopprice));
If(Low<stopprice && BarsSinceEntry>0) sell(0,Min(open,stopprice));
End
|
|