
merci pour le partage

Code : #
// Paramètres
ATRPeriods = 14
ATRMultiplier = c // variable à tester
// Calcul de l'ATR
myATR = AverageTrueRange[ATRPeriods]
// Seuil de volatilité extrême à définir
ATRThreshold = average[50](myATR) * ATRMultiplier
// Filtre
IF myATR < ATRThreshold THEN
// Condition pour entrer en position
Code : #
// Calcul de l'écart type sur 50 périodes
Vol = STD[50](close)
Multiplier=c // variable à définir
// Seuil basé sur la moyenne
VolThreshold = average[100](Volatility) * c
// Filtre
vo2= Vol < VolThreshold
// Entrer en position
Code : #
// Définition du range et du corps de la bougie
CandleRange = high - low
CandleBody = abs(close - open)
// Filtrer les bougies avec une forte volatilité relative
vo3 = CandleRange > CandleBody * c // variable à définir
// Ne pas trader sur cette bougie
Code : #
bbupper = BollingerUp[20](close)
bblower = BollingerDown[20](close)
bbwidth = bbupper - bblower
// Seuil de volatilité basé sur une moyenne
bbthreshold = average[50](bbwidth) * c // variable à définir
// Filtre
vo4 = bbwidth < bbthreshold
// Accepter les trades seulement dans des conditions de volatilité modérée
Code : #
if longonmarket then
nATR = x // Période de l'ATR
facteurTP =y // Multiplicateur du TP
// Calcul de la volatilité
ATRValue = AverageTrueRange[nATR]
// Définition du Take Profit basé sur l'ATR
TakeProfit = ATRValue * facteurTP
Set target pprofit z + TakeProfit
Code : #
Stop = 1,5 × ATR(14)
Code : #
positionSize = capital * risqueParTrade / (1.5 * ATR)
Code : #
IF time >= 1530 AND time <= 1600 THEN
// éviter de trader
ENDIF
Code : #
// --- PARAMÈTRES ---
periodeATR = 14
seuilATR = 20 // À ajuster selon la volatilité normale de ton actif
delaiBlocage = 30 // Nombre de bougies sans trader après déclenchement
// --- CALCUL DE LA VOLATILITÉ ---
atr = AverageTrueRange[periodeATR](close)
// --- KILL SWITCH ---
IF atr > seuilATR THEN
killSwitch = delaiBlocage
ENDIF
IF killSwitch > 0 THEN
tradingAutorise = 0
killSwitch = killSwitch - 1
ELSE
tradingAutorise = 1
ENDIF
// --- UTILISATION DANS TON ALGO ---
IF tradingAutorise = 1 THEN
// ici tes conditions d'entrée classiques
IF conditionLong THEN
BUY 1 CONTRACT AT MARKET
ENDIF
Code : #
// ----- PARAMÈTRES -----
periodeADX = 14
seuilADX = 20 // Si l'ADX passe sous ce seuil → fin de tendance
periodeMMcourte = 8
periodeMMlongue = 21
// ----- INDICATEURS -----
adx = ADX[periodeADX](close)
mmCourte = Average[periodeMMcourte](close)
mmLongue = Average[periodeMMlongue](close)
// ----- SIGNAL DE FIN DE TENDANCE -----
// 1. Croisement MM (retour contre tendance)
retournementBaissier = mmCourte CROSSES UNDER mmLongue
retournementHaussier = mmCourte CROSSES OVER mmLongue
// 2. ADX chute sous le seuil (perte de force)
faibleMomentum = adx < seuilADX
// ----- SORTIE OU SÉCURISATION -----
// Exemples d’action : sortir si on est en position et tendance s’essouffle
IF positionlong AND (retournementBaissier OR faibleMomentum) THEN
SELL AT MARKET
ENDIF
IF positionshort AND (retournementHaussier OR faibleMomentum) THEN
EXITSHORT AT MARKET
ENDIF
Code : #
// ----- PARAMÈTRES -----
lookback = 5 // Nombre de bougies pour détecter les sommets/creux locaux. Plus c’est petit, plus c’est réactif ; plus c’est grand, plus c’est fiable.
// ----- DÉTECTION DES SOMMETS ET CREUX -----
highestHigh = Highest[lookback](high)
lowestLow = Lowest[lookback](low)
IF high = highestHigh THEN
top = high
barTop = barindex
ENDIF
IF low = lowestLow THEN
bottom = low
barBottom = barindex
ENDIF
// ----- MISE EN MÉMOIRE DES DEUX DERNIERS SOMMETS ET CREUX -----
IF barTop <> lastBarTop THEN
top2 = top1
top1 = top
lastBarTop = barTop
ENDIF
IF barBottom <> lastBarBottom THEN
bottom2 = bottom1
bottom1 = bottom
lastBarBottom = barBottom
ENDIF
// ----- DÉTECTION DU CHANGEMENT DE STRUCTURE -----
structureHaussiere = top1 > top2 AND bottom1 > bottom2
structureBaissiere = top1 < top2 AND bottom1 < bottom2
// ----- CHANGEMENT DE STRUCTURE -----
IF structureHaussiere AND (top1 < top2 OR bottom1 < bottom2) THEN
signalFinHaussier = 1
ELSE
signalFinHaussier = 0
ENDIF
IF structureBaissiere AND (top1 > top2 OR bottom1 > bottom2) THEN
signalFinBaissier = 1
ELSE
signalFinBaissier = 0
ENDIF
// ----- EXEMPLE DE SORTIE DE POSITION -----
IF positionlong AND signalFinHaussier THEN
SELL AT MARKET
ENDIF
IF positionshort AND signalFinBaissier THEN
EXITSHORT AT MARKET
ENDIF