开拓者 TB用matlab测试出来一个比较不错的交易系统 [开拓者 TB]
用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- TB技术人员: 找到原因了,原来是编程习惯造成的
if 后面没有括号 - TB客服:
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 262069696 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容