Bonjour, j avais du temps j ai travailler avec l’ I.A . Cela donne beaucoup de variables, bon courage… Bon, je post quand même si un autre peut aider. Au mieux c ‘est une base, au pire : poubelle.
// Paramètres
DEFPARAM CumulateOrders = False
DEFPARAM PRELOADBARS = 10000
// Heikin-Ashi definition
once xOpen = open
xClose = (open + close + high + low) / 4
if barindex > 0 then
xOpen = (xOpen + xClose[1]) / 2
endif
xLow = min(low,min(xClose,xOpen))
xHigh = max(high,max(xClose,xOpen))
xTypic = (xHigh + xLow + xClose) / 3
xMed = (xHigh + xLow) / 2
xRange = xHigh – xLow
// Variables
cumV = 0
lastpeakhigh = high
lastpeakvol = 0
lasttoughlow = low
lasttoughvol = 0
peak = 0 // Initialisez la variable peak à 0
tough = 0 // Initialisez la variable tough à 0
zz = 0 // Initialisez la variable zz à 0
peakhigh = 0 // Initialisez la variable peakhigh à 0
peakvol = 0 // Initialisez la variable peakvol à 0
toughlow = 0 // Initialisez la variable toughlow à 0
toughvol = 0 // Initialisez la variable toughvol à 0
// — Courbe Coppock
// Déclaration des paramètres
ROCPeriod1 = 14
ROCPeriod2 = 11
EMAPeriod = 6
// Variables pour stocker les valeurs précédentes
prevClose1 = 0.0
prevClose2 = 0.0
// Calcul du taux de variation (ROC) à partir du prix de clôture
ROC1 = ((CLOSE – prevClose1) / prevClose1) * 100
ROC2 = ((CLOSE – prevClose2) / prevClose2) * 100
// Mise à jour des valeurs précédentes
prevClose1 = CLOSE[ROCPeriod1]
prevClose2 = CLOSE[ROCPeriod2]
// Calcul de la somme des taux de variation
SumROC = ROC1 + ROC2
// Calcul de la moyenne mobile exponentielle (EMA) de la somme des taux de variation
Coppock = ExponentialAverage[EMAPeriod](SumROC)
// — Conditions d’achat
Condition1 = Coppock > 0 AND Coppock[1] <= 0
Condition2 = cumV > 0
// — Conditions de vente
Condition3 = zz < 0 AND zz[1] >= 0
// Achat à l’ouverture de la prochaine période si les conditions sont remplies
IF Condition1 AND Condition2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Vente à découvert à l’ouverture de la prochaine période si la condition de vente est remplie
IF Condition3 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// — Affichage des divergences
// Bearish Divergence
IF peak AND peakhigh > lastpeakhigh AND peakvol < lastpeakvol THEN
divbear = peakvol
//DRAWSEGMENT(lastpeakbar, lastpeakvol, peakbar, peakvol) COLOURED(r, g, 0)
//DRAWARROWDOWN(peakbar, peakvol) COLOURED(r, g, 0)
ENDIF
// Bullish Divergence
IF tough AND toughlow < lasttoughlow AND toughvol < lasttoughvol THEN
divbull = toughvol
//DRAWSEGMENT(lasttoughbar, lasttoughvol, toughbar, toughvol) COLOURED(r, g, 0)
//DRAWARROWUP(toughbar, toughvol) COLOURED(r, g, 0)
ENDIF
// Gestion de la sortie de position
//************************************************************************
// Trailing stop function
trailingstart = 20 // trailing will start @trailinstart points profit
trailingstep = 5 // trailing step to move the “stoploss”
// Reset the stoploss value
IF NOT ONMARKET THEN
newSL = 0
ENDIF
// Gérer les positions longues
IF LONGONMARKET THEN
// Premier mouvement (breakeven)
IF newSL = 0 AND close – tradeprice(1) >= trailingstart * pipsize THEN
newSL = tradeprice(1) + trailingstep * pipsize
ENDIF
// Mouvements suivants
IF newSL > 0 AND close – newSL >= trailingstep * pipsize THEN
newSL = newSL + trailingstep * pipsize
ENDIF
ENDIF
// Gérer les positions courtes
IF SHORTONMARKET THEN
// Premier mouvement (breakeven)
IF newSL = 0 AND tradeprice(1) – close >= trailingstart * pipsize THEN
newSL = tradeprice(1) – trailingstep * pipsize
ENDIF
// Mouvements suivants
IF newSL > 0 AND newSL – close >= trailingstep * pipsize THEN
newSL = newSL – trailingstep * pipsize
ENDIF
ENDIF
// Stop order pour sortir des positions
IF newSL > 0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************