Bonjour à tous, je me permets de répondre sur ce vieux sujet pour obtenir de l’aide.
J’essaie une stratégie de convergence de couleur Heikin-Ashi sur 3 UT pour ça, pas de problème. (Je mets d’ailleurs le code si ça peut servir à d’autres)
Cependant je ne parviens pas à configurer un stop suiveur derrière l’ouverture de l’avant dernière bougie Heikin-Ashi. Je ne sais même pas vraiment vérifier si ce que j’ai fait fonctionne :-/
Merci d’avance pour votre aide précieuse
timeframe(3000 minutes)
//heikin-ashi pour UT2
xCloseUT3 = (Open+High+Low+Close)/4
if(barindex>2) then
xOpenUT3 = (xOpenUT3[1] + xCloseUT3[1])/2
endif
//condition d'achat pour UT3
HAVertUT3 = xCloseUT3>xOpenUT3 AND xCloseUT3[1]<xOpenUT3[1]
//condition de vente pour UT3
HARougeUT3 = xCloseUT3<xOpenUT3 AND xCloseUT3[1]>xOpenUT3[1]
timeframe(300 minutes)
//heikin-ashi pour UT2
xCloseUT2 = (Open+High+Low+Close)/4
if(barindex>2) then
xOpenUT2 = (xOpenUT2[1] + xCloseUT2[1])/2
endif
//condition d'achat pour UT2
HAVertUT2 = xCloseUT2>xOpenUT2 AND xCloseUT2[1]<xOpenUT2[1]
//condition de vente pour UT2
HARougeUT2 = xCloseUT2<xOpenUT2 AND xCloseUT2[1]>xOpenUT2[1]
timeframe(default)
xCloseUT1 = (Open+High+Low+Close)/4
if(barindex>2) then
xOpenUT1 = (xOpenUT1[1] + xCloseUT1[1])/2
endif
//condition d'achat pour UT1
HAVertUT1 = xCloseUT1>xOpenUT1 AND xCloseUT1[1]<xOpenUT1[1]
//condition de vente pour UT1
HARougeUT1 = xCloseUT1<xOpenUT1 AND xCloseUT1[1]>xOpenUT1[1]
//on achète si toutes les UT convergentes
if HAVertUT2 and HAVertUT3 and HAVertUT1 then
BUY 1 SHARE AT MARKET
endif
//on vend si toutes les UT convergentes
if HARougeUT2 and HARougeUT3 and HARougeUT1 then
SELLSHORT 1 SHARE AT MARKET
endif
//stop suiveur derrière l'avant dernière bougie <------------------------------- BESOIN DE VOUS A PARTIR D'ICI
IF LONGONMARKET THEN
SL = xOpenUT1[1]
SELL AT SL STOP
ENDIF
IF SHORTONMARKET THEN
SL = xOpenUT[1]
BUY AT SL STOP
ENDIF
GRAPHONPRICE SL coloured(178,34,34) AS "SL"
Pour fermer une position de vente à découvert, il faut utiliser l’instruction EXITSHORT (remplacer BUY à la ligne 55).
Avec ton GRAPHONPRICE, tu devrais correctement visualiser ton stop suiveur sur le graphique du prix te permettant de débugger le calcul de ce niveau si nécessaire. Sans avoir testé par moi même, après lecture du code, l’ensemble me semble correct.
Bonjour Nicolas,
Merci pour ta réponse. En effet, l’erreur était EXITSHORT à la place de BUY.
J’en profite pour te féliciter pour ton excellent travail sur le forum et ailleurs.
perso j ai ce message d erreur…
Salut,
C’est la fin du code qui pose problème. je mets une version corrigée.
timeframe(3000 minutes)
//heikin-ashi pour UT2
xCloseUT3 = (Open+High+Low+Close)/4
if(barindex>2) then
xOpenUT3 = (xOpenUT3[1] + xCloseUT3[1])/2
endif
//condition d'achat pour UT3
HAVertUT3 = xCloseUT3>xOpenUT3 AND xCloseUT3[1]<xOpenUT3[1]
//condition de vente pour UT3
HARougeUT3 = xCloseUT3<xOpenUT3 AND xCloseUT3[1]>xOpenUT3[1]
timeframe(300 minutes)
//heikin-ashi pour UT2
xCloseUT2 = (Open+High+Low+Close)/4
if(barindex>2) then
xOpenUT2 = (xOpenUT2[1] + xCloseUT2[1])/2
endif
//condition d'achat pour UT2
HAVertUT2 = xCloseUT2>xOpenUT2 AND xCloseUT2[1]<xOpenUT2[1]
//condition de vente pour UT2
HARougeUT2 = xCloseUT2<xOpenUT2 AND xCloseUT2[1]>xOpenUT2[1]
timeframe(default)
xCloseUT1 = (Open+High+Low+Close)/4
if(barindex>2) then
xOpenUT1 = (xOpenUT1[1] + xCloseUT1[1])/2
endif
//condition d'achat pour UT1
HAVertUT1 = xCloseUT1>xOpenUT1 AND xCloseUT1[1]<xOpenUT1[1]
//condition de vente pour UT1
HARougeUT1 = xCloseUT1<xOpenUT1 AND xCloseUT1[1]>xOpenUT1[1]
//on achète si toutes les UT convergentes
if HAVertUT2 and HAVertUT3 and HAVertUT1 then
BUY 1 SHARE AT MARKET
endif
//on vend si toutes les UT convergentes
if HARougeUT2 and HARougeUT3 and HARougeUT1 then
SELLSHORT 1 SHARE AT MARKET
endif
//stop suiveur derrière l'avant dernière bougie
IF LONGONMARKET THEN
SL = xOpenUT1[1]
SELL AT SL STOP
ENDIF
IF SHORTONMARKET THEN
SL = xOpenUT1[1]
EXITSHORT AT SL STOP
ENDIF
GRAPHONPRICE SL coloured(178,34,34) AS "SL"