Bonjour tout le monde,
Le code en pièce jointe donne un résultat horrible, l’ equity cuve est cependant intéressante car pertes successives très régulières.
Peut on écrire ce code à l’ envers, afin d’ inverser l’ equity cuve, ce qui donnerait un beau résultat ?
// Définition des paramètres du code
DEFPARAM CumulateOrders = False
DEFPARAM PreLoadBars = 15000
macdCourt = 12
macdLong = 26
macdLissage = 9
stFacteur = 4
stPeriode = 30
ligneMacd = MACDLine[macdCourt,macdLong,macdLissage](close)
ligneSignal = MACDSignal[macdCourt,macdLong,macdLissage](close)
histoMacd = ligneMacd – ligneSignal
valeurST = Supertrend[stFacteur,stPeriode]
tendanceHausse = close > valeurST
tendanceBaisse = close < valeurST
croisementBas = histoMacd CROSSES UNDER 0
croisementHaut = histoMacd CROSSES OVER 0
// Deux baisses consecutives, histogramme courant encore positif.
deuxBaisses = histoMacd < histoMacd[1] AND histoMacd[1] < histoMacd[2]
// Deux hausses consecutives, histogramme courant encore negatif.
deuxHausses = histoMacd > histoMacd[1] AND histoMacd[1] > histoMacd[2]
sortieLong = (histoMacd > 0 AND deuxBaisses) OR tendanceBaisse
sortieShort = (histoMacd < 0 AND deuxHausses) OR tendanceHausse
IF LongOnMarket THEN
IF sortielong THEN
SELL AT MARKET
ENDIF
ELSIF ShortOnMarket THEN
IF sortieShort THEN
EXITSHORT AT MARKET
ENDIF
ELSE
IF tendanceHausse AND croisementBas THEN
BUY 1 CONTRACT AT MARKET
ELSIF tendanceBaisse AND croisementHaut THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
ENDIF
//Objectif gain
SET TARGET PROFIT gain
SET STOP LOSS perte
Merci beaucoup.