- 精华
- 0
- 在线时间
- 466 小时
- UID
- 110420
- 积分
- 547
- 帖子
- 326
- 阅读权限
- 50
- 注册时间
- 2012-5-11
- 最后登录
- 2019-1-11
- 精华
- 0
- UID
- 110420
- 积分
- 547
- 帖子
- 326
- 主题
- 16
- 阅读权限
- 50
- 注册时间
- 2012-5-11
- 最后登录
- 2019-1-11
|
本帖最后由 受伤的小鱼 于 2012-12-23 18:41 编辑
受伤的小鱼 发表于 2012-12-23 17:09
在做“拟合”之时,我首先想到的还是取一根均线,当均线的方向向上或向下时,我对突破的倍数有不同,正如 ...
而在采用另一种方法时,就象上面的TX说的,此模型的核心理念在于ATR,那么我对TR进行优化
于是
atrvlu的定义就是当。。。。。。。
还是直接贴代码吧。。。。。。
Params
Numeric atrlen(19);
Numeric aatrlen(19);
Numeric atrvlu(1.30);
Numeric atrvld(1.30);
Numeric atrvsu(2.50);
Numeric atrvsd(2.50);
Numeric stln(1);
Numeric stlfd(100);
Numeric stffd(100);
Vars
Numeric offs;
NumericSeries atr;
NumericSeries aatr;
Numeric uprail;
Numeric lorail;
Numeric lprice;
Numeric sprice;
BoolSeries entry01;
BoolSeries exit01;
BoolSeries exit02;
BoolSeries exit03;
BoolSeries exit04;
Numeric stlpr;
Numeric stfpr;
Begin
offs=MinMove*PriceScale;
atr=Average(h-l,atrlen);
aatr=Average(atr,aatrlen);
if (atr[1]>=aatr[1]) uprail=open+atrvlu*atr[1];
if (atr[1]< aatr[1]) uprail=open+atrvld*atr[1];
if (atr[1]>aatr[1]) lorail=open-atrvsu*atr[1];
if (atr[1]<=aatr[1]) lorail=open-atrvsd*atr[1];
lprice=uprail+2*offs;
sprice=lorail-2*offs;
stlpr=Min(open,LastEntryPrice*(1-stlfd/1000))-2*offs;
stfpr=Max(open,lastentryprice*(1+stffd/1000));
entry01=high>uprail;
Exit01=low<lorail;
exit02=low<LastEntryPrice*(1-stlfd/1000);
exit03=MarketPosition==1 and BarsSinceEntry>stln and low<low[1];
exit04=MarketPosition==1 and high>lastentryprice*(1+stffd/1000);
if (exit03) Sell(0,Min(open,low[1])-2*offs);
if (MarketPosition<>1 and entry01 ) Buy(0,lprice);
if (MarketPosition==1 and exit01 ) Sell(0,sprice);
if (exit02) Sell(0,stlpr);
if (exit04) Sell(0,stfpr);
//if (time==0.1500) Sell(0,close-offs);
//Commentary("swag"+Text(CountIf (entry01 and exit01,CurrentBar)));
end
空头的程序就不写了,语句是是全对称多头的写法,也是因为想让测试报告好看,所以参数不一样,对了顺便提一下,对于空头的交易atrvsu和atrvsd的区别使模型效果带来巨变
顺便贴测试结果吧,刚下午在论坛上看到一TX贴的模型,单个我也拿不出手,我也找个压箱底的组合组合吧
但。。。都是历史而已。。。。。。。。。。
|
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
|