- 精华
- 0
- 在线时间
- 144 小时
- UID
- 264292
- 积分
- 27
- 帖子
- 16
- 阅读权限
- 10
- 注册时间
- 2018-4-10
- 最后登录
- 2020-11-2
- 精华
- 0
- UID
- 264292
- 积分
- 27
- 帖子
- 16
- 主题
- 8
- 阅读权限
- 10
- 注册时间
- 2018-4-10
- 最后登录
- 2020-11-2
|
本帖最后由 a4585574 于 2018-10-26 14:16 编辑
小米 发表于 2018-10-24 15:08
空头持仓时,currentcontracts的值是负数,而在buytocover的交易手数是不可为负的。 ...
版主,能否麻烦您再帮忙看看这段代码为何开多仓后亏50点不止损
If(MarketPosition == 0 And exitdate!=Truedate(0))
{
If(High>= BuyPosition)
{ SellShort(Lots,Max(Open,BuyPosition)+i_offset);
Return;
}
If(Low<= SellPosition)
{ Buy(Lots,Min(Open,SellPosition)-i_offset);
Return;
}
}
If(MarketPosition == -1)
{
If(Low<= SellPosition)
{
Buy(Lots,Min(Open,sellPosition)-i_offset);
Return;}
}
If(MarketPosition == 1)
{
If(High>= BuyPosition )
SellShort(Lots,Max(Open, BuyPosition)+i_offset);
Return;}
}
If(MarketPosition == 1)
{
If( Low<=AvgEntryPrice-50)
Sell(Lots,AvgEntryPrice-50);
}
If(MarketPosition == -1)
{
If(high>=avgentryprice+50)
BuyToCover(Lots,avgentryprice+50);
}
|
|