- 精华
- 0
- 在线时间
- 48 小时
- UID
- 225852
- 积分
- 11
- 帖子
- 8
- 阅读权限
- 10
- 注册时间
- 2015-12-28
- 最后登录
- 2017-10-21
- 精华
- 0
- UID
- 225852
- 积分
- 11
- 帖子
- 8
- 主题
- 3
- 阅读权限
- 10
- 注册时间
- 2015-12-28
- 最后登录
- 2017-10-21
|
老师好。我编的程序中的赋值语句 Concrossunder = crossunder(close,downline);中的 Concrossunder和downline都已经定义为数值型序列值,可是编译时老说数据类型不一致,调整了多次,这个问题就是解决不了拉。源代码如下:Params
Numeric validbars1(50);//两次下穿之间保持有效的bar数
Numeric validbars2(3);//满足开仓条件后的有效bar数
Vars
NumericSeries midline;//布林中轨
NumericSeries upline;//布林上轨
NumericSeries refClose;//前收盘价
NumericSeries concrossunder;//当前bar是否下穿下轨
NumericSeries downline;//布林下轨
NumericSeries concrossover;//当前bar是否上穿上轨
Numeric barsfstcrsund;//最近倒数第二次下穿离现在的bar数
Numeric barsseccrsund;//最近的一次下穿离现在的bar数
Numeric MyEntryPrice;//开仓价格
Numeric MyExitPrice;//平仓价格
Boolseries entryflag(false);//开仓标志
NumericSeries entrypoint;//开仓价格
NumericSeries entrycount;//满足开仓条件的bar计数
Begin
If(BarStatus==0)
{
Return;
}
If(CurrentBar>20)
{
refClose=Close[1];
midline=Average(refClose,20);
downline=midline-2*StandardDev(refClose,20);
upline=midline+2*StandardDev(refClose,20);
Concrossunder = crossunder(close,downline);
//计算最近两次下穿发生的bar离当前bar的根数
Barsfstcrsund=nthcon(concrossunder==true,2);
barsseccrsund=nthcon(concrossunder==true,1);
}
//设置开仓标志
If(concrossunder and barsseccrsund-Barsfstcrsund<=50 and open>close(Barsfstcrsund))
{entryflag=true;
Entrypoint=open;
Entrycount=0;
}
//开仓
If(marketposition==0 and Entrycount<=validbars2)
{
If(entryflag and vol>0)
{ MyEntryPrice=open;
buy(0,open);
}
}
If(MarketPosition==1)
{ Concrossover=crossover(close,upline);
If(concrossover)
{
sell(0,open);
}
}
If(MarketPosition==1)
{
If(close[1]<MyEntryPrice-7)
{
sell(0,open);
}
}
End
恳请高手指点。先谢了! |
|