Un code de breakout en tendance (pour Ashley)


At the request of Ashley, I tried to backtest a strategy.

It was a failure on M15 and H1.
But the code works well for these conditions :

  • H4 timeframe
  • only long positions (works not great with shorts)

On H1, we must use « sell limit » instead of « buy stop », it works with it !

So this code isn’t my best strategy of course, but the equity curve is sexy 🙂


PS : désolé pour les francophones exclusifs, mais la traduction n’est pas très dure…





Voici le code du BACKTEST :


// ASHLEY's strategy
// EUR/USD  H4  minicontracts

EMA21 = exponentialaverage[21]
EMA40 = exponentialaverage[40]
EMA100 = exponentialaverage[100]

n = 4

Ctime = time > 040000 and time < 200000

ca1 = EMA21 > EMA40 and EMA40 > EMA100
ca2 = EMA21 > EMA21[1] and EMA40 > EMA40[1] and EMA100 > EMA100[1]
ca3 = low < EMA21 and close > EMA21
ca4 = close > open and close > close[1] and close > open[1] and open <= open[1] and open <= close[1]

IF Ctime and ca1 and ca2 and ca3 and ca4 and not longonmarket THEN
SL = close - low
buy n shares at highest[1](high) stop

set stop loss SL
set target profit SL * 1.5