- 精华
- 0
- 在线时间
- 18 小时
- UID
- 226891
- 积分
- 6
- 帖子
- 4
- 阅读权限
- 10
- 注册时间
- 2016-1-17
- 最后登录
- 2017-6-14
- 精华
- 0
- UID
- 226891
- 积分
- 6
- 帖子
- 4
- 主题
- 2
- 阅读权限
- 10
- 注册时间
- 2016-1-17
- 最后登录
- 2017-6-14
|
以下是我的思路,即开仓后,应该按照预期平仓,或者是按照预期止损,可是在整个交易周期中,止盈和止损都没有出现过,
求问这是什么原因,万分感谢!!!折腾好久了。。。快吐了。。。。
Params
numeric a(18);
numeric b(3);
numeric c(36);
Vars
numericseries residual;
Begin
residual=data1.close[0]-2.6*data0.close[0]-986.5;
PlotNumeric("residual",data1.close[0]-2.6*data0.close[0]-986.5);
if(marketposition==0 and residual>a) '开仓条件
{
data0.Buy(1,data0.close) and data1.SellShort(1,data1.close);
while(data0.marketposition==1 and data1.MarketPosition==-1 and residual>b and residual<-b) '止盈条件
{
data0.Sell(1,data0.close) and data1.BuyToCover(1,data1.close);
}
while(data0.marketposition==1 and data1.MarketPosition==-1 and residual>c) '止损条件
{
data0.Sell(1,data0.close) and data1.BuyToCover(1,data1.close);
}
}
if(marketposition==0 and residual<-a)
{
data1.Buy(1,data1.close) and data0.SellShort(1,data0.close);
while(data1.marketposition==1 and data0.MarketPosition==-1 and residual>b and residual<-b) '止盈条件
{
data1.Sell(1,data1.close) and Data0.BuyToCover(1,data0.close);
}
while(data1.marketposition==1 and data0.MarketPosition==-1 and residual<-c) '止损条件
{
data1.Sell(1,data1.close) and data0.BuyToCover(1,data0.close);
}
}
End |
|