Three-MA Price Breakthrough Strategy

Data cycle: multiple cycles

Data contract: index contract

Trading contract: main contract

Suitable for: commodity futures

(*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);


Backtest on FMZ Quant to know more

Source Codehttps://www.fmz.com/strategy/128130

Add a Comment

Your email address will not be published. Required fields are marked *