Brent Oil 5 minutes trading strategy

Category: Strategies By: Kenneth Kvistad Created: August 21, 2016, 7:12 PM
August 21, 2016, 7:12 PM
Strategies
85 Comments

It is an automated strategy used for Brent oil CFD on 5 minute chart with good results since October 2015 as i don’t have more data to run it.  Trailing stop code from Nicolas.

If anyone is able to run the backtest for a longer time  then please post it here.  As you will see, there is no 0 bars on the backtest.  Any idea for improving the code is welcome.

DEFPARAM CumulateOrders = False // Cumulating positions deactivated

//defparam flatbefore = 230000
//defparam flatafter = 065500

// Conditions to enter long positions
indicator1 = TimeSeriesAverage[12](close)
indicator2 = WilderAverage[60](close)
c1 = (indicator1 >= indicator2)

indicator3 = SMI[14,2,16](close)
c2 = (indicator3 CROSSES OVER -44)

IF c1 AND c2 THEN
 BUY 2 CONTRACT AT MARKET
ENDIF

// Conditions to enter short positions
indicator4 = TimeSeriesAverage[28](close)
indicator5 = WilderAverage[88](close)
c3 = (indicator4 <= indicator5)

indicator6 = SMI[8,1,16](close)
c4 = (indicator6 >= 45)

IF c3 AND c4 THEN
 SELLSHORT 2 CONTRACT AT MARKET
ENDIF

//////////////////////////////////////////////////////////////////////////
////Trailing stop logikk
//////////////////////////////////////////////////////////////////////////
//trailing stop
trailingstop = 34

//resetting variables when no trades are on market
if not onmarket then
 MAXPRICE = 0
 MINPRICE = close
 priceexit = 0
endif

//case SHORT order
if shortonmarket then
 MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
 if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
  priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
 endif
endif

//case LONG order
if longonmarket then
 MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
 if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
  priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
 endif
endif

//exit on trailing stop price levels
if onmarket and priceexit>0 then
 EXITSHORT AT priceexit STOP
 SELL AT priceexit STOP
endif

SET STOP ploss 62//20
SET TARGET pPROFIT 98//54

 

Download
Filename: brent-crude-eur1-mini-Live-acc..png
Downloads: 468
Download
Filename: Brent-Oil-5MIN-strategy.itf
Downloads: 1014
Kenneth Kvistad Senior
Currently debugging life, so my bio is on hold. Check back after the next commit for an update.
Author’s Profile

Comments

Logo Logo
Loading...