资源加载中... loading...

双均线DDI策略

Author: 扫地僧, Date: 2021-11-04 14:56:43
Tags: 商品期货趋势My语言

  • 策略思路:双均线确定方向,用DDI指标,确定进场时点,比例止损和回撤止盈

  • 数据周期:15M

  • 策略适用:数字货币、商品期货

  • 官方网站:www.quantinfo.com

  • 主图指标线: VAR2^^MA(C,PARAM2); VAR3^^MA(VAR2,PARAM1);

  • 副图指标线: VAR9:MA(VAR8,2*PARAM1); VAR10:MA(VAR9,PARAM1); VAR8:VAR6-VAR7;

img


(*backtest
start: 2018-11-01 00:00:00
end: 2018-12-14 00:00:00
period: 15m
exchanges: [{"eid":"Futures_BitMEX","currency":"XBT_USD"}]
args: [["TradeAmount",100,126961],["ContractType","XBTUSD",126961]]
*)

VAR2^^MA(C,PARAM2);
VAR3^^MA(VAR2,PARAM1);

VAR4:=IFELSE((HIGH+LOW)<=(REF(HIGH,1)+REF(LOW,1)),0,MAX(ABS(HIGH-REF(HIGH,1)),ABS(LOW-REF(LOW,1)))),NODRAW;
VAR5:=IFELSE((HIGH+LOW)>=(REF(HIGH,1)+REF(LOW,1)),0,MAX(ABS(HIGH-REF(HIGH,1)),ABS(LOW-REF(LOW,1)))),NODRAW;
VAR6:=SUM(VAR4,PARAM1)/(SUM(VAR4,PARAM1)+SUM(VAR5,PARAM1)),NODRAW;
VAR7:=SUM(VAR5,PARAM1)/(SUM(VAR5,PARAM1)+SUM(VAR4,PARAM1)),NODRAW;
VAR8:VAR6-VAR7;
VAR9:MA(VAR8,2*PARAM1);
VAR10:MA(VAR9,PARAM1);

BUYK:=BARPOS>PARAM2 AND C>VAR2 AND VAR2>VAR3 AND VAR8>0 AND VAR9>VAR10;
SELLK:=BARPOS>PARAM2 AND C<VAR2 AND VAR2<VAR3 AND VAR8<0 AND VAR9<VAR10;

SELLY:=C<VAR2 AND C>BKPRICE*(1+0.01*PARAM3);
BUYY:=C>VAR2 AND C<SKPRICE*(1-0.01*PARAM3);

SELLS:=C<BKPRICE*(1-PARAM3*0.01);
BUYS:=C>SKPRICE*(1+PARAM3*0.01);

BKVOL=0 AND BUYK,BK;
SKVOL=0 AND SELLK,SK;

SELLS,SP(BKVOL);
BUYS,BP(SKVOL);

SELLY,SP(BKVOL);
BUYY,BP(SKVOL);
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6