- 精华
- 0
- 在线时间
- 40 小时
- UID
- 1928
- 积分
- 115
- 帖子
- 12
- 阅读权限
- 30
- 注册时间
- 2008-7-18
- 最后登录
- 2019-3-31
- 精华
- 0
- UID
- 1928
- 积分
- 115
- 帖子
- 12
- 主题
- 4
- 阅读权限
- 30
- 注册时间
- 2008-7-18
- 最后登录
- 2019-3-31
|
请帮忙看看下面这个模板哪里出了问题:
Params
Numeric BuyLots(1);
Numeric SellLots(1);
Vars
NumericSeries conFailureCnt(0);
Numericseries X;
Bool Condition1;
Bool Condition2;
Bool Condition3;
Bool Condition4;
Begin
If(BarStatus==0)
{
conFailureCnt = 0;
}else
{
conFailureCnt = conFailureCnt[1];
}
Condition1 =
Condition2 =
Condition3 =
Condition4 =
X = 500
if (Condition1 && Condition3 && MarketPosition == 0)
{
Buy(BuyLots,Close,true);
}
if (marketposition == 1)
{
If(conFailureCnt == 1)
{
Buy(BuyLots,Close,true);
}
If(conFailureCnt == 2)
{
Buy(BuyLots,Close,true);
}
If(conFailureCnt == 3)
{
Buy(BuyLots,Close,true);
}
}
if (Condition2)
{
Sell(0,close,true);
conFailureCnt = 0;
}
if (Condition2 && Condition4 && MarketPosition == 0)
{
SellShort(SellLots,Close,true);
}
if (marketposition == -1)
{
If(conFailureCnt == 1)
{
SellShort(SellLots,Close,true);
}
If(conFailureCnt == 2)
{
SellShort(SellLots,Close,true);
}
If(conFailureCnt == 3)
{
SellShort(SellLots,Close,true);
}
}
if (Condition1)
{
BuyToCover(0,close,true);
conFailureCnt = 0;
}
If(MarketPosition <>0 )
{
If(ContractProfit > X)
{
conFailureCnt = conFailureCnt + 1;
}
}
End
我的设想是持仓后,每手盈利一超过X就加一仓,因为加了仓后每手盈利会降低,所以再次每手盈利达到X的时候,又可以加一手,不论多空.可是按照我这程序,执行的时候多单胡乱加仓,不管盈亏,空单从不加仓 |
|