- 精华
- 0
- 在线时间
- 112 小时
- UID
- 5975
- 积分
- 277
- 帖子
- 47
- 阅读权限
- 50
- 注册时间
- 2009-11-24
- 最后登录
- 2019-1-18
- 精华
- 0
- UID
- 5975
- 积分
- 277
- 帖子
- 47
- 主题
- 10
- 阅读权限
- 50
- 注册时间
- 2009-11-24
- 最后登录
- 2019-1-18
|
回复 6# lh948
Params
Bool bInitStatus(False);
Numeric InitMyRealMp(0);
Numeric FirstGrid(30);
Numeric TrailingGrid(30);
Numeric EveryLots(1);
Numeric Offset(1);
Numeric ExitOnCloseMins(14.58);
Vars
Numeric HighAfterLongEntry;
Numeric LowAfterShortEntry;
Numeric MyRealMp(0);
Numeric MinPoint;
Numeric TmpPrice;
Numeric TmpLots;
Begin
MinPoint = MinMove*PriceScale;
MyRealMp = GetGlobalVar(0);
HighAfterLongEntry = GetGlobalVar(1);
LowAfterShortEntry = GetGlobalVar(2);
If(BarStatus == 0 && (MyRealMp == InvalidNumeric || bInitStatus ))
{MyRealMp = InitMyRealMp;}
HighAfterLongEntry = Max(HighAfterLongEntry,High);
LowAfterShortEntry = Min(LowAfterShortEntry,Low);
If(MyRealMp == 0 && High-LowAfterShortEntry>=FirstGrid*MinPoint)
{
TmpPrice = Min(LowAfterShortEntry+(FirstGrid+Offset)*MinPoint,High);
TmpLots = EveryLots;
Buy(TmpLots,TmpPrice);
MyRealMp = 1;
HighAfterLongEntry = High;
}Else
If(MyRealMp ==0 && HighAfterLongEntry-Low>=FirstGrid*MinPoint)
{
TmpPrice = Max(HighAfterLongEntry-(FirstGrid-Offset)*MinPoint,Low);
TmpLots = EveryLots;
SellShort(TmpLots,TmpPrice);
MyRealMp = -1;
LowAfterShortEntry = Low;
}
//止损
If(MyRealMp>0 && HighAfterLongEntry-Low>=TrailingGrid*MinPoint&&
(High-Low<TrailingGrid*MinPoint Or (High-Low>=TrailingGrid*MinPoint &&
Close[1]<Open)))
{
TmpPrice = Max(HighAfterLongEntry-(TrailingGrid-Offset)*MinPoint,Low);
TmpLots = Abs(MyRealMp*EveryLots);
Sell(TmpLots,TmpPrice);
MyRealMp = 0;
LowAfterShortEntry = Low;
}Else
If(MyRealMp<0 && High-LowAfterShortEntry>=TrailingGrid*MinPoint &&(High-Low<TrailingGrid*MinPoint Or (High-Low>=TrailingGrid*MinPoint &&
Close[1]>Open)))
{
TmpPrice = Min(LowAfterShortEntry+(TrailingGrid+Offset)*MinPoint,High);
TmpLots = Abs(MyRealMp*EveryLots);
BuyToCover(TmpLots,TmpPrice);
MyRealMp = 0;
HighAfterLongEntry = High;
}
SetGlobalVar(0,MyRealMp);
SetGlobalVar(1,HighAfterLongEntry);
SetGlobalVar(2,LowAfterShortEntry);
Commentary("MyRealMp="+Text(MyRealMp));
Commentary("HighAfterLongEntry="+Text(HighAfterLongEntry));
Commentary("LowAfterShortEntry="+Text(LowAfterShortEntry));
Commentary("浮动盈亏="+Text(PositionProfit));
End
代码如上~请指教~谢谢 |
|