- 精华
- 0
- 在线时间
- 4 小时
- UID
- 90779
- 积分
- 39
- 帖子
- 8
- 阅读权限
- 10
- 注册时间
- 2012-1-3
- 最后登录
- 2012-10-26
- 精华
- 0
- UID
- 90779
- 积分
- 39
- 帖子
- 8
- 主题
- 4
- 阅读权限
- 10
- 注册时间
- 2012-1-3
- 最后登录
- 2012-10-26
|
Params
Bool bInitStatus(false);//初始化标志,修改初始仓位时需设置为True
Numeric InitMyRealMp(0); //初始当前仓位,正数表示多单
Numeric FirstGrid(10);//第一笔交易的间距,最小跳动
Numeric AddGrid(2);//加仓间距,最小跳动
Numeric TotalGrids(3);//最大交易次数
Numeric TrailingGrid(10); //移动止损间距,最小跳动
Numeric EveryLots(2);//每次开仓手数
Numeric OffSet(1); //委托价偏差,默认买卖价偏差1个滑点
Numeric ExitOnCloseMins(14.58);//收盘平仓时间
Vars
Numeric HighAfterLongEntry;
Numeric LowAfterShotEntry;
Numeric MyRealMp(0);
Numeric MinPoint;
Numeric TmpPrice;
Numeric TmpLots;
Begin
MinPoint = MinMove*PriceScale;
MyRealMp = GetGlobalVar(0);
HighAfterLongEntry = GetGlobalVar(1);
LowAfterShotEntry = GetGlobalVar(2);
If(BarStatus==0 And (MyRealMp==InvalidNumeric||bInitStatus ))
{
MyRealMp = InitMyRealMp;
}
If(Date <> Date[1])
{
HighAfterLongEntry = High;
LowAfterShotEntry = Low;
MyRealMp = 0;
}Else
{
HighAfterLongEntry = Max(HighAfterLongEntry,High);
LowAfterShotEntry = Min(LowAfterShotEntry,Low);
}
If(Time<ExitOnCloseMins/100 )
{
If((BarType==1 or BarType==2) && BarStatus == 2 && date!=date[1] && high==low) return;
If (MyRealMp > 0 And HighAfterLongEntry-Low>=TrailingGrid*MinPoint)//平
{
TmpPrice = Max(HighAfterLongEntry - (TrailingGrid-OffSet)*MinPoint,Low);
TmpLots = Abs(MyRealMp*EveryLots);
Sell(TmpLots,TmpPrice);
MyRealMp = 0;
LowAfterShotEntry=Low;
}
If(MyRealMp == 0 And High - LowAfterShotEntry>=FirstGrid*MinPoint)//开仓
{
TmpPrice = Min(LowAfterShotEntry+(FirstGrid+OffSet)*MinPoint,High);
TmpLots = EveryLots;
Buy(TmpLots,TmpPrice);
MyRealMp = 1;
HighAfterLongEntry = High;
}Else If(MyRealMp > 0 And MyRealMp<TotalGrids And High- LowAfterShotEntry>=(FirstGrid+MyRealMp*AddGrid)*MinPoint)//加
{
TmpPrice = Min(LowAfterShotEntry+(FirstGrid+MyRealMp*AddGrid+OffSet)*MinPoint,High);
TmpLots = EveryLots;
Buy(TmpLots,TmpPrice);
MyRealMp=MyRealMp+1;
} |
|