Bonjour Nicolas,
J’ai repris le code concernant le THREE LINE BREAK pour essayer de le mettre en stratégie
ci-joint le code et plus l’explication de mon souci.
DEFPARAM CUMULATEORDERS = false // pas de cumul de positions
DEFPARAM Preloadbars = 10000
DEFPARAM FLATBEFORE = 070000
DEFPARAM FLATAFTER = 220000
// ACTIVATION OU NON DES LONGS / SHORTS
// 0 = désactiver / 1 = activer
LongsOK = 1
ShortsOK = 1
// TAILLE DES POSITIONS
REINV = 1
LEVIER = 1 // Levier d'origine 5
n = levier
// STOPS
SL = 45 // POSSIBILITE DE MONTER A 50 POINTS
// CALCUL DES CONDITIONS POUR TROUVER LE SIGNAL D'ACHAT OU DE VENTE
if barindex = 1 then //barindex
if (close >= open) then
xtrend = 1
trend = xtrend
xu = close
xu1 = open
xu2 = open
xu3 = open
CL = xu
OP = xu1
LL = OP
HH = CL
ELSE
xtrend = -1
trend = xtrend
xu = close
xu1 = open
xu2 = open
xu3 = open
CL = xu
OP = xu1
LL = CL
HH = OP
ENDIF
ELSE //barindex continue
if (xtrend = 1) then
if (close > xu) then
trend = xtrend
xu3 = xu2
xu2 = xu1
xu1 = xu
xu = close
CL = xu
OP = xu1
LL = OP
HH = CL
ELSIF (close < xu3) then
xtrend = -1
trend = xtrend
xu = close
xu2 = xu1
xu3 = xu1
CL = xu
OP = xu1
LL = CL
HH = OP
ELSE
trend = xtrend
CL = CL[1]
OP = OP[1]
LL = LL[1]
HH = HH[1]
ENDIF
ELSE //xtrend <>1
if (close > xu3) then
xtrend = 1
trend = xtrend
xu = close
xu2 = xu1
xu3 = xu1
CL = xu
OP = xu1
LL = OP
HH = CL
ELSIF (close < xu) then
trend = xtrend
xu3 = xu2
xu2 = xu1
xu1 = xu
xu = close
CL = xu
OP = xu1
LL = CL
HH = OP
ELSE
trend = xtrend
CL = CL[1]
OP = OP[1]
LL = LL[1]
HH = HH[1]
ENDIF
ENDIF
ENDIF
// LONGS
IF TREND >0 THEN
IF LongsOK = 1 THEN
IF not longonmarket THEN
Buy n shares at market
SET STOP pLOSS SL
// SHORTS
IF trend <0 then
IF ShortsOK = 1 THEN
IF not shortonmarket THEN
Sellshort n shares at market
SET STOP pLOSS SL
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
je joins le screen avec le souci.
à 9h03 on ouvre LONG et je ne comprend pas pourquoi avec le chandelier de 10h06 la stratégie n’est pas arrêté
Merci pour ta réponse Nicolas
Cordialement
Non testé, mais pour moi tu t’es emmêlé dans tes ENDIF, tu as placé la partie short dans la partie long. Ci-dessous le code corrigé à tester:
DEFPARAM CUMULATEORDERS = false // pas de cumul de positions
DEFPARAM Preloadbars = 10000
DEFPARAM FLATBEFORE = 070000
DEFPARAM FLATAFTER = 220000
// ACTIVATION OU NON DES LONGS / SHORTS
// 0 = désactiver / 1 = activer
LongsOK = 1
ShortsOK = 1
// TAILLE DES POSITIONS
REINV = 1
LEVIER = 1 // Levier d'origine 5
n = levier
// STOPS
SL = 45 // POSSIBILITE DE MONTER A 50 POINTS
// CALCUL DES CONDITIONS POUR TROUVER LE SIGNAL D'ACHAT OU DE VENTE
if barindex = 1 then //barindex
if (close >= open) then
xtrend = 1
trend = xtrend
xu = close
xu1 = open
xu2 = open
xu3 = open
CL = xu
OP = xu1
LL = OP
HH = CL
ELSE
xtrend = -1
trend = xtrend
xu = close
xu1 = open
xu2 = open
xu3 = open
CL = xu
OP = xu1
LL = CL
HH = OP
ENDIF
ELSE //barindex continue
if (xtrend = 1) then
if (close > xu) then
trend = xtrend
xu3 = xu2
xu2 = xu1
xu1 = xu
xu = close
CL = xu
OP = xu1
LL = OP
HH = CL
ELSIF (close < xu3) then
xtrend = -1
trend = xtrend
xu = close
xu2 = xu1
xu3 = xu1
CL = xu
OP = xu1
LL = CL
HH = OP
ELSE
trend = xtrend
CL = CL[1]
OP = OP[1]
LL = LL[1]
HH = HH[1]
ENDIF
ELSE //xtrend <>1
if (close > xu3) then
xtrend = 1
trend = xtrend
xu = close
xu2 = xu1
xu3 = xu1
CL = xu
OP = xu1
LL = OP
HH = CL
ELSIF (close < xu) then
trend = xtrend
xu3 = xu2
xu2 = xu1
xu1 = xu
xu = close
CL = xu
OP = xu1
LL = CL
HH = OP
ELSE
trend = xtrend
CL = CL[1]
OP = OP[1]
LL = LL[1]
HH = HH[1]
ENDIF
ENDIF
ENDIF
// LONGS
IF TREND >0 THEN
IF LongsOK = 1 THEN
IF not longonmarket THEN
Buy n shares at market
SET STOP pLOSS SL
endif
endif
endif
// SHORTS
IF trend <0 then
IF ShortsOK = 1 THEN
IF not shortonmarket THEN
Sellshort n shares at market
SET STOP pLOSS SL
ENDIF
ENDIF
ENDIF
Merci Nicolas
faut que je me réveille depuis ce matin c’est dur
je regarde ça et tiens au courant
Cordialement
Bonjour Nicolas,
testé ça marche. les résultats sont moyens suivant les unités de temps.
du travail pour améliorer
Bonne journée, Cordialement