- 精华
- 1
- 在线时间
- 277 小时
- UID
- 42516
- 积分
- 1239
- 帖子
- 264
- 阅读权限
- 60
- 注册时间
- 2011-5-25
- 最后登录
- 2014-9-23
- 精华
- 1
- UID
- 42516
- 积分
- 1239
- 帖子
- 264
- 主题
- 31
- 阅读权限
- 60
- 注册时间
- 2011-5-25
- 最后登录
- 2014-9-23
|
本帖最后由 rookies 于 2012-5-25 18:06 编辑
Params
Numeric Lots(1);
Vars
Numeric MaEma30;
Numeric MaEma23;
NumericSeries MyEntryPrice;
NumericSeries MyExitPrice;
Begin
MaEma30=XAverage(Close,30);
MaEma23=XAverage(Close,23);
PlotNumeric("MaEma30",MaEma30);
PlotNumeric("MaEma23",MaEma23);
If(CurrentBar>23)
{
If(Close>MaEma30 && Close>MaEma23 && Close[1]<Max(MaEma30,MaEma23) &&MarketPosition!=1 ) //收盘价大于30、23天EMA且没有多单
{
MyEntryPrice=High; //将当天最高价置入
}
Else
{
MyExitPrice=MyExitPrice[1];
}
If(High>MyEntryPrice && MarketPosition!=1 && MyEntryPrice!=0)
{
Buy(Lots,Max(Open,MyEntryPrice));
MyEntryPrice=0;
Return;
}
If(Close<MaEma30 && Close<MaEma23 && Close[1]>Min(MaEma30,MaEma23)&& MarketPosition!=-1)// && GetGlobalVar(1)!=-1)
{
MyExitPrice=Low;
}
Else
{
MyExitPrice=MyExitPrice[1];
}
If(Low<MyExitPrice && MarketPosition!=-1 && MyExitPrice!=0)
{
SellShort(Lots,Min(Open,MyExitPrice));
MyExitPrice=0;
}
}
Commentary("MyEntryPrice"+Text(MyEntryPrice));
Commentary("MyExitPrice"+Text(MyExitPrice));
Commentary("GetGlobalVar(0)"+Text(GetGlobalVar(0)));
Commentary("GetGlobalVar(1)"+Text(GetGlobalVar(1)));
End
不知道是不是楼主想要的效果? |
|