快捷搜索:  汽车  科技

生成dem两种方法的优势(DualThrust策略设计)

生成dem两种方法的优势(DualThrust策略设计)Vars: HH( 0) HC (0) LC(0) LL( 0); vars: sellrange(0 ) buyrange (0) buytrig(0) selltrig(0 ); Nday (1) lots(1);//交易手数 vars: dayclose(0 ) dayhigh(0 ) daylow (0);

#科技萌新成长营# Dual_Thrust策略程序设计。这个程序我在2018年写过一份,今年5月份对它进行重新设计。

2018年版本的核心代码如下:

inputs:

Mday(1 )

Nday (1)

lots(1);//交易手数

vars: dayclose(0 ) dayhigh(0 ) daylow (0);

vars: sellrange(0 ) buyrange (0) buytrig(0) selltrig(0 );

Vars: HH( 0) HC (0) LC(0) LL( 0);

vars: buyposition(0 ) sellposition (0);

vars: opentoday(0 );

if date <> date[1] then begin

opentoday=open ;

end;

HH=highest (high Mday ) of data2 ;

HC=highest (close Mday ) of data2 ;

LL=lowest (low Mday ) of data2 ;

LC=lowest (close Mday ) of data2 ;

condition11=adx(14) of data2>dvalue of data2;

condition12=adx(14) of data2>kvalue of data2;

condition21=adx(14) >dvalue ;

condition22=adx(14) >kvalue ;

condition15=AverageFC(c ma20len)>AverageFC(c ma60len);

condition16=AverageFC(c ma20len)<AverageFC(c ma60len);

if (HH-LC)>=( HC- LL) then sellrange=HH -LC

else sellrange =HC -LL ;

HH = Highest (High Nday ) of data2 ;

HC = Highest (Close Nday ) of data2 ;

LL = Lowest (Low Nday ) of data2 ;

LC = Lowest (Close Nday ) of data2 ;

If((HH - LC) >= ( HC - LL ))then buyrange = HH - LC

Else buyrange = HC - LL;

buytrig = k1* buyrange;

selltrig = k2* sellrange;

buyposition = opentoday buytrig ;

sellposition = opentoday -selltrig ;

if MarketPosition = 0 then begin

If High >=buyposition and condition11 then

Buy lots shares next bar at buyposition stop ;

If Low <=sellposition and condition12 then

SellShort lots shares next bar at sellposition stop;

end;

end;

以上是源代码的绩效并不是很好,现在对其进行重新加工设计。

对以上代码进行了如下重新设计:

1,对K线进行了重新设计;

2,对ADX指标进行了重新设计;改造后的代码如下:

ADX_map(adx_length) >Average(adx_map(adx_length) adx_length) ;

增加了如下过滤:

1,增加BOLL线做为过滤,这是很常规的过滤方法。

value11=close ;

AveMa=Average(value11 boll_Length);

StdValue = StandardDev(value11 boll_Length 0);

UpperBand=hullma StdDevUp*StdValue;

LowerBand=hullma-StdDevUp*StdValue;

交易的主程序如下:

if value61>hullma_data2 and marketPosition = 0 and condition55 then begin

If C>ma_p and c<ma_p*(1 buy_nn) and c>UpperBand and hullma_var0>SLOP_REG and c cross over buyposition then//High >=buyposition AND

Buy("d1") lots shares next bar at market ;

end;

if value61<hullma_data2 and marketPosition = 0 and data2_hullma_var0<-SLOP_REG and condition55 then begin

If Low <=sellposition AND hullma_var0<-SLOP_REG AND C<ma_p and c>ma_p*(1-buy_nn) and c<LowerBand and c cross under sellposition then SellShort("k1") lots shares next bar at market;

end;

程序改完之后,样本外数据信号如下(下图为2分钟K线周期,副图K线是小时K线):

生成dem两种方法的优势(DualThrust策略设计)(1)

图1

看起来信号不错,我看下其曲线及业绩

生成dem两种方法的优势(DualThrust策略设计)(2)

图2

生成dem两种方法的优势(DualThrust策略设计)(3)

图3

生成dem两种方法的优势(DualThrust策略设计)(4)

图4

业绩还行,希望大家能够喜欢。如果喜欢 请关注点赞。

猜您喜欢: