Dear all
I have elaborated a little over an idea originally posted in the forum by Bjoern posted as True Range Breakout EUR/USD.
I applied to the Dax with the additional feature of switching from a breakout to a mean reversion strategy depending on some optimized value of the ADX indicator.
The strategy is a breakout strategy when the adx is above a certain value and a mean reverting strategy when ADX value is below that same value.
I have optimized it on several time frame and the results look quite promising, it would be great if someone think of a better way of discriminate between range trading vs trending phases. I have used the popular ADX indicator, but I am sure there are more efficient way to look at phase transitions in market.
The results for different time frames are attached, together with the 30minutes code.
Best Regards
Francesco
DEFPARAM CumulateOrders = False
DEFPARAM FLATBEFORE =080000
DEFPARAM FLATAFTER =210000
adxval = 20
ATRperiod = 12
adxperiod = 15
indicator1 = adx[adxperiod]
atr = AverageTrueRange[ATRperiod]
m = 3
n = 2
c1 = indicator1 <adxval
c2 = indicator1 >adxval
if c1 then
// short
IF (abs(open-close) > (atr*m) and close > open) THEN
sellshort 1 CONTRACTS AT MARKET
//SET STOP pLOSS losses
//SET TARGET pPROFIT profits
ENDIF
//long
IF (abs(open-close) > (atr*m) and close < open) THEN
buy 1 CONTRACTS AT MARKET
//SET STOP pLOSS losses
//SET TARGET pPROFIT profits
ENDIF
endif
if c2 then
// long
IF (abs(open-close) > (atr*n) and close > open and close> Dhigh(1)) THEN
buy 1 CONTRACTS AT MARKET
//SET STOP pLOSS losses
//SET TARGET pPROFIT profits
ENDIF
//short
IF (abs(open-close) > (atr*n) and close < open and close< Dlow(1)) THEN
sellshort 1 CONTRACTS AT MARKET
//SET STOP pLOSS losses
//SET TARGET pPROFIT profits
ENDIF
endif