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

开收盘均价差ATR策略

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

  • 策略进场:开盘价和收盘价均价差决定趋势,与ATR结合,进场点也是反向出场点;

  • 策略出场:开仓就定好止损点,趋势转向出场;

  • 数据周期:日线

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

  • 官方网站:www.quantinfo.com

  • 主图: 无

  • 副图: 显示:ATR,公式 ATR^^MA(TR,N); 显示 :C_O,公式 C_O:EMA(C,N)-EMA(O,N);

img


(*backtest
start: 2018-10-01 00:00:00
end: 2018-11-30 00:00:00
period: 1d
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES","balance":20000}]
*)

// 变量
// variable

LOTS:=MAX(1,INTPART(MONEYTOT/(O*UNIT*0.1)));
C_O:EMA(C,N)-EMA(O,N);
B:=CROSSUP(C_O,0);
S:=CROSSDOWN(C_O,0);
TR:=MAX(MAX((H-L),ABS(REF(C,1)-H)),ABS(REF(C,1)-L));
ATR:MA(TR,N);
BAND:=ATR*0.1*M;
PRICE_BPK:=VALUEWHEN(B,H+BAND);
PRICE_SP:=VALUEWHEN(B,L-BAND);
PRICE_SPK:=VALUEWHEN(S,L-BAND);
PRICE_BP:=VALUEWHEN(S,H+BAND);

// 策略逻辑
// strategy logic
BARPOS>N AND C_O>0  AND C>=PRICE_BPK,BPK(LOTS);
BARPOS>N AND C_O<0  AND C<=PRICE_SPK,SPK(LOTS);

// 下单
// place an order
S,SP(BKVOL);
B,BP(SKVOL);

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