// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
DEFPARAM FLATBEFORE = 080500
// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
DEFPARAM FLATAFTER = 175500
// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
lMMv1 = average[3](close)
lMMv2 = average[5](close)
lMMv3 = average[8](close)
lMMv4 = average[10](close)
lMMv5 = average[12](close)
lMMv6 = average[15](close)
lMMr1 = average[30](close)
lMMr2 = average[35](close)
lMMr3 = average[40](close)
lMMr4 = average[45](close)
lMMr5 = average[50](close)
lMMr6 = average[60](close)
lMMtrend = average[300, 0](close)
vMin = min(min(min(min(min(lMMv1,lMMv2),lMMv3),lMMv4),lMMv5),lMMv6)
vMax = max(max(max(max(max(lMMv1,lMMv2),lMMv3),lMMv4),lMMv5),lMMv6)
rMin = min(min(min(min(min(lMMr1,lMMr2),lMMr3),lMMr4),lMMr5),lMMr6)
rMax = max(max(max(max(max(lMMr1,lMMr2),lMMr3),lMMr4),lMMr5),lMMr6)
// Condition 1 : détection de la tendance
c1a = close > lMMtrend
c1b = close < lMMtrend
// Condition 2 : Toutes les bandes du même côté de la tendance
c2a = vMin > lMMTrend and rMin > lMMTrend
c2b = vMax < lMMTrend and rMax < lMMTrend
// Condition 3 : la plus basse vert dépasse la plus haute rouge
c3a = vMin > rMax + 10
c3b = vMax < rMin - 10
if longonmarket and not (c1a and c2a and c3a) then
// Changement de
supertrend
sell
at market
doClose = 1
elsif shortonmarket and not (c1b and c2b and c3b) then
// Changement de supertrend
exitshort at market
doClose = 1
endif
if c1a and c2a and c3a and (not onmarket or doClose) and not daysForbiddenEntry THEN
BUY 1 SHARES AT MARKET
doClose = 0
elsif c1b and c2b and c3b and (not onmarket or doClose) and not daysForbiddenEntry THEN
SELLSHORT 1 SHARES AT MARKET
doClose = 0
ENDIF
// Stops et objectifs
SET STOP pLOSS 50
//SET TARGET pPROFIT xTP