Loading ...

Three-MA Price Breakthrough Strategy

Author: littleDreamXX, Date: 2018-11-30 09:21:43
Tags: Trend Commodity-futures MA MyLanguage

  • Data cycle: multiple cycles

  • Data contract: index contract

  • Trading contract: main contract

  • Suitable for: commodity futures

    img


(*backtest
start: 2018-01-01 00:00:00
end: 2018-02-28 00:00:00
period: 1h
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES","balance":20000}]
*)

LOTS:=MAX(1,INTPART(MONEYTOT/(O*UNIT*0.1)));

MA1^^MA(C,N1);
MA2^^MA(C,N2);
MA3^^MA(C,N3);

BUYK:=BARPOS>N3 AND BKVOL=0 AND MA1>MA2 AND MA2>MA3 AND C>MA1;
SELLK:=BARPOS>N3 AND SKVOL=0 AND MA1<MA2 AND MA2<MA3 AND C<MA1;
BUYP:=SKVOL>0 AND CROSS(C,MA2) AND C>MA1 AND C<=SKPRICE*(1-2*SLOSS*0.01);
SELLP:=BKVOL>0 AND CROSS(MA2,C) AND MA1>C AND C>=BKPRICE*(1+2*SLOSS*0.01);

BUYK,BK(LOTS);
SELLK,SK(LOTS);

// 止盈
// take profit
BUYP,BP(SKVOL);
SELLP,SP(BKVOL);

// 止损
// stop loss
C>=SKPRICE*(1+SLOSS*0.01),BP(SKVOL);
C<=BKPRICE*(1-SLOSS*0.01),SP(BKVOL);

Related

More