- 精华
- 0
- 在线时间
- 138 小时
- UID
- 69712
- 积分
- 103
- 帖子
- 27
- 阅读权限
- 30
- 注册时间
- 2011-10-6
- 最后登录
- 2014-2-2
- 精华
- 0
- UID
- 69712
- 积分
- 103
- 帖子
- 27
- 主题
- 6
- 阅读权限
- 30
- 注册时间
- 2011-10-6
- 最后登录
- 2014-2-2
|
If(MarketPosition==1) // 有多仓的情况
{
if(mywinbuy+safeline<0)//可以在这里写上初始的止损处理
{
MyExitPrice = MyEntryPrice - StopLossSet*MinPoint;
If(Open < MyExitPrice) MyExitPrice = Open; //如果该Bar开盘价有跳空触发,则用开盘价代替
Sell(0,MyExitPrice);
blongentry=False;
bshortentry=True;
mytradeaccount=mytradeaccount+1;
buydiff = ExitPrice-myEntryPrice;//计算平多后是否盈利
if(buydiff < 0 and bshortentry and mytradeaccount<a)
{
sellshort(0,close);
} else if (mytradeaccount==a)
{
bshortentry=False;
}
} else If(HighestAfterEntry[1] >= MyEntryPrice + TrailingStart5*MinPoint) // 第5级跟踪止损的条件表达式
{
If(Low <= HighestAfterEntry[1] - TrailingStop5*TrailingStart5*MinPoint)
{
MyExitPrice = HighestAfterEntry[1] - TrailingStop5*TrailingStart5*MinPoint;
If(Open < MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替
Sell(0,MyExitPrice);
blongentry=False;
PlotString("zhiying","止赢",(Low-0.5*MinMove),Red);
}
}
}else if(MarketPosition==-1) // 有空仓的情况
{
if(mywinsell+safeline<0)//可以在这里写上初始的止损处理
{
MyExitPrice = MyEntryPrice + StopLossSet*MinPoint;
If(Open > MyExitPrice) MyExitPrice = Open;//如果该Bar开盘价有跳空触发,则用开盘价代替
BuyToCover(0,MyExitPrice);
bshortentry=False;
blongentry=True;
mytradeaccount=mytradeaccount+1;
selldiff = myEntryPrice-ExitPrice;//计算平空后是否盈利
if(selldiff < 0 and blongentry and mytradeaccount<a)
{
Buy(0,close);
} else if (mytradeaccount==a)
{
blongentry=False;
}
} else If(LowestAfterEntry[1] <= MyEntryPrice - TrailingStart5*MinPoint) // 第5级跟踪止损的条件表达式
{
If(High >= LowestAfterEntry[1] + TrailingStart5*TrailingStop5*MinPoint)
{
MyExitPrice = LowestAfterEntry[1] + TrailingStart5*TrailingStop5*MinPoint;
If(Open > MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替
BuyToCover(0,MyExitPrice);
bshortentry=False;
PlotString("zhiying","止赢",(Low-0.5*MinMove),Red);
}
}
} |
|