mahanxiong 发表于 2013-10-6 13:26:57

提高回测质量的一种方法

本帖最后由 mahanxiong 于 2013-10-6 13:28 编辑

废话不多说,看代码就可以了。
//------------------------------------------------------------------------
// 简称: newway
// 名称: NewwayToCreatAndBacktesSystems
// 类别: 公式应用
// 类型: 用户应用
// 对于下跌的bar:o>>>h>>>l>>>c,上涨的bar HL反过来。
// 大概的意思就是通过代码来按顺序模拟一根bar开盘到收盘的过程从而避免TB每个bar只过一次的缺点。大家看代码就明白了。有需要的同学可以模拟12个点。
// 甚至可以去调用M1的bar的信息。这就能达到接近MT4的回测质量了。
// 对于不知道我在干啥的童鞋,忽略这个帖子。。。
//------------------------------------------------------------------------
Params
//这不是个用来实盘的系统,这里啥也没有。。。

Vars
NumericSeries hh;
NumericSeries ll;

Begin
//假装现在当前bar开盘
hh=Highest(h,60);
ll=lowest(l,60);
If(o>hh && MarketPosition<1) Buy(1,o);
If(o<ll && MarketPosition>-1) SellShort(1,o);

If(c>o)//上涨的bar
{
//时光继续飞逝,假装这个bar已经运行到了最低价
If(l>hh && MarketPosition<1) Buy(1,l);
If(l<ll && MarketPosition>-1) SellShort(1,l);

//时光飞逝,假装这个bar已经运行到了最高价
If(h>hh && MarketPosition<1) Buy(1,h);
If(h<ll && MarketPosition>-1) SellShort(1,h);

}

If(c<o)//下跌的bar
{
//时光飞逝,假装这个bar已经运行到了最高价
If(h>hh && MarketPosition<1) Buy(1,h);
If(h<ll && MarketPosition>-1) SellShort(1,h);

//时光继续飞逝,假装这个bar已经运行到了最低价
If(l>hh && MarketPosition<1) Buy(1,l);
If(l<ll && MarketPosition>-1) SellShort(1,l);
}

//要收盘了
If(c>hh && MarketPosition<1) Buy(1,c);
If(c<ll && MarketPosition>-1) SellShort(1,c);

End


//------------------------------------------------------------------------
// 编译版本        GS2010.12.08
// 用户版本        2013/10/06 11:22
// 版权所有        mahanxiong
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------

受伤的小鱼 发表于 2013-10-7 02:55:18

着实不知道你在干嘛

mahanxiong 发表于 2013-10-7 09:42:32

受伤的小鱼 发表于 2013-10-7 02:55 static/image/common/back.gif
着实不知道你在干嘛

lol~

liq77 发表于 2013-10-7 10:31:08

不必这么麻烦。通常采用1m图表来提高回测质量,已经足够了。

topgun0791 发表于 2016-7-26 10:33:51

页: [1]
查看完整版本: 提高回测质量的一种方法