- 精华
- 0
- 在线时间
- 21 小时
- UID
- 111622
- 积分
- 36
- 帖子
- 9
- 阅读权限
- 10
- 注册时间
- 2012-7-20
- 最后登录
- 2013-5-26
- 精华
- 0
- UID
- 111622
- 积分
- 36
- 帖子
- 9
- 主题
- 3
- 阅读权限
- 10
- 注册时间
- 2012-7-20
- 最后登录
- 2013-5-26
|
用matlab测试出来一个比较不错的交易系统,用TB实现的时候,卡在这里了,急求帮助啊!
代码如下
Params
Numeric my_Entryprice(0);
Numeric bar_keep(1);
Numeric profits_lost_ratio(0.01);
Vars
Numeric high_price;
Numeric low_price;
Numeric i;
Numeric profits_lost_state(0);
Begin
high_price=high[bar_keep];
low_price=low[bar_keep];
for i= bar_keep DownTo 1
{
If(close[i] > high_price)
high_price =close[i];
if(close[i] < low_price)
low_price =close[i];
}
if (MarketPosition==1)
{ If high_price-my_Entryprice>=profits_lost_ratio*OpenD(0) // 达到止盈条件
{ if (-close[1]+high_price)>=(high_price-my_Entryprice)*0.5
{
profits_lost_state=1;
return;
}
}
if high_price-my_Entryprice>=profits_lost_ratio*OpenD(0)*2
{ if (-close[1]+high_price)>=(high_price-my_Entryprice)*0.3
{
profits_lost_state=1;
return;
}
}
if high_price-my_Entryprice>=profits_lost_ratio*OpenD(0)*3
{ if (-close[1]+high_price)>=(high_price-my_Entryprice)*0.1
{
profits_lost_state=1;
return;
}
}
if -close[1]+my_Entryprice>=profits_lost_ratio*OpenD(0) // 达到止损条件
{
profits_lost_state=-1;
return;
}
}
if (MarketPosition==-1)
{ if -low_price+my_Entryprice>=profits_lost_ratio*OpenD(0) // 达到止盈条件
{ if (close[1]-low_price)>=(-low_price+my_Entryprice)*0.5
{
profits_lost_state=1;
return;
}
}
if -low_price+my_Entryprice>=profits_lost_ratio*OpenD(0)*2
{ if (close[1]-low_price)>=(-low_price+my_Entryprice)*0.3
{
profits_lost_state=1;
return;
}
}
if -low_price+my_Entryprice>=profits_lost_ratio*OpenD(0)*3
{ if (close[1]-low_price)>=(-low_price+my_Entryprice)*0.1
{
profits_lost_state=1;
return;
}
}
if close[1]-my_Entryprice>=profits_lost_ratio*OpenD(0) // 达到止损条件
{
profits_lost_state=-1;
return;
}
}
}
Return profits_lost_state;
End
编译的时候:无法识别的是high_price |
|