Bonjour à tous,
Récemment, j’ai publié une stratégie simple de trading manuel :
.
Grâce à l’intervention de « Kévin », nous avons ici une petite adaptation sur la paire USD/JPY M30.
En analysant le code, vous voyez qu’il y a eu quelques ajouts.
L’important est de retenir que la stratégie peut être efficace, de base. Rien n’empêche de l’optimiser un peu.
.

.
Voici le code du BACKTEST :
DEFPARAM CUMULATEORDERS = false
n = 1
EMA1 = exponentialaverage[13](close)
EMA2 = exponentialaverage[34](close)
macdHisto = (EMA1 - EMA2) - exponentialAverage[9](EMA1 - EMA2)
ca1 = macdHisto[1] crosses over 0
ca2 = close > average[230](close)
ca3 = EMA1 < EMA2
cv1 = macdHisto[1] crosses under 0
cv2 = close < average[230](close)
cv3 = EMA1 > EMA2
// INDICATEUR MOMENTUM
OTa = Momentum[26]
momentumCA1 = OTa > OTa[6]
MLTa = Momentum[280]
momentumCA2 = MLTa > MLTa[7]
OTv = Momentum[4]
momentumCV1 = OTv < OTv[7]
MLTv = Momentum[180]
momentumCV2 = MLTv < MLTv[26]
startTime = 60000
endTime = 190000
ratioTPSL = 3
ratioBreakEven = 2
minSL = 10
maxSL = 35
condition = countOfPosition = 0 and time >= startTime and time <= endTime
condA = ca1 and ca2 and ca3 and momentumCA1 and momentumCA2 and condition
condV = cv1 and cv2 and cv3 and momentumCV1 and momentumCV2 and condition
if condA or condV then
lastPositionBarIndex = barindex
lastPositionPrice = close
breakeven = 0
if condA then
// long
SL = (close - lowest[10](low)) / POINTSIZE
SL = min(max(SL, minSL), maxSL)
TP = SL * ratioTPSL
buy n shares at market
set stop ploss SL
set target pprofit TP
else
//short
SL = (highest[10](high) - close) / POINTSIZE
SL = min(max(SL, minSL), maxSL)
TP = SL * ratioTPSL
sellshort n shares at market
set stop ploss SL
set target pprofit TP
endif
endif
// Si nous ne nous trouvons pas sur la bougie d'entrée
// Et s'il y a une position ouverte
// Et si le breakeven n'a pas déjà été placé
if lastPositionBarIndex < barindex and countOfPosition > 0 and breakeven = 0 then
if countOfShortShares > 0 then
perf = (lastPositionPrice - close) / POINTSIZE
else
perf = (close - lastPositionPrice) / POINTSIZE
endif
// Si la performance de la position en cours est supérieure ou égale au SL * ratioBreakEven
// On met le SL à breakeven
if perf >= SL * ratioBreakEven then
set stop $loss lastPositionPrice
breakeven = 1
endif
endif