Rob Hofmann trend following strategy. Oil 1hr.

Category: Strategies By: Francesco78 Created: June 12, 2017, 7:19 AM
June 12, 2017, 7:19 AM
Strategies
3 Comments

Dear all, I have been listening to a class by Rob Hofmann yesterday and I though it was worth try to code it.

The strategy is based on the follwoing principles

  • Bearmarket->bullish hammer candle (signal candle) -> sell stop order somewhere along  the signal candle
  • Bullmarket-> bearish hammer candle > buy stop order somewhere along the candle.

Should be applicable to many assets and many timeframes.

I post the example of OIL 1hr TF.

Looking forward for your comments

Best

Francesco

///Rob Hoffman idea of trend following mechanism
//crude oil 1hr spread 1

DEFPARAM cumulateorders = FALSE

///indicators used to define market trend
average1 = average[5](close)
average2 = average[20](close)
average3 = average[50](close)
average4 = average[100](close)
atr = averagetruerange[14]


///optimized variable
ml = 9// dynamic factors for profit and stops
nl = 4
ms = 6
ns = 4

c = 2.8// factor used to calibrate the shape of the hammer candle used as a signal

gradient = 1 // slope of moving averages


////defining the bull trend conditions
bulltrend1 = average1-average1[2] >gradient and average1< close
bulltrend2 = average1-average2[2] >gradient and average2< close
bulltrend3 = average3-average3[2] >gradient and average3<  close
bulltrend4 = average4-average4[2] >gradient and average4 < close
bulltrend = bulltrend1 and bulltrend2 and bulltrend3 and bulltrend4
/////defining the bear trend conditions
beartrend1 = average1-average1[2] <-gradient and close < average1
beartrend2 = average1-average2[2] <-gradient and close < average2
beartrend3 = average3-average3[2] <-gradient and close < average3
beartrend4 = average4-average4[2] <-gradient and close < average4
beartrend = beartrend1 and beartrend2 and beartrend3 and beartrend4
///defining the signal candles
hammerup = abs(open-close)< (High - low)/2 and close> high -(high-low)/c and open > high - (high-low)/c //
hammerdown = abs(open-close)< (High - low)/2 and close< low +(high-low)/c and open < low + (high-low)/c //


///defining the level for the stop orders
if hammerdown and bulltrend  then
 levelup = high-(high-low)/2
endif

if hammerup and beartrend  then
 leveldown =low + (high-low)/2
endif
///trading conditions
if bulltrend then
 buy 1 contract at levelup stop
endif

if beartrend then
 sellshort  1 contract at leveldown stop
endif
///dynamic profit and stops
if longonmarket then
 set target pprofit ml*atr
 set stop ploss nl*atr
endif

if shortonmarket then
 set target pprofit ms*atr
 set stop ploss ns*atr
endif

Download
Filename: hofmannstratoil1hr.itf
Downloads: 423
Download
Filename: hofmann_wf.png
Downloads: 166
Francesco78 Master
Code artist, my biography is a blank page waiting to be scripted. Imagine a bio so awesome it hasn't been coded yet.
Author’s Profile

Comments

Logo Logo
Loading...