bonjour, j’ai fais un code avec chat gpt qui marche sur TW pour afficher la STO en reverse engenering
le voici
//@version=5
indicator(“Stochastic Reverse Engineering (K=200, D=200)”, overlay = true)
// Inputs
k_period = 200 // Période de %K fixée à 200
d_period = 200 // Période de %D fixée à 200
smoothK = input(3, title=”Smooth K”)
// Calcul du Stochastique %K
lowestLow = ta.lowest(low, k_period)
highestHigh = ta.highest(high, k_period)
k = 100 * (close – lowestLow) / (highestHigh – lowestLow)
// Lisser %K
smoothedK = ta.sma(k, smoothK)
// Calcul du %D
d = ta.sma(smoothedK, d_period)
// Normaliser %K et %D pour les rendre visibles sur le graphique des prix
k_normalized = (smoothedK / 100) * (highestHigh – lowestLow) + lowestLow
d_normalized = (d / 100) * (highestHigh – lowestLow) + lowestLow
// Tracer les lignes %K et %D sur le graphique des prix
plot(d_normalized, title=”%D (200)”, color=color.orange, linewidth=2)
j’ai essayé une conversion mais impossible au niveau du calcul de K, je ne comprend pas pourquoi il parle de nombre entier.
Si vous avez une solution?
// Paramètres
kp = 200 // Période de %K fixée à 200
dp = 200 // Période de %D fixée à 200
smoothK = 3 // Lissage de %K
// Calcul du Stochastique %K
lowestLow = lowest[kp](low)
highestHigh = highest[kp](high)
k = 100 * (close - lowestLow) / (highestHigh - lowestLow)
// Lissage de %K
smoothedK = average[k](smoothK)
// Calcul du %D
d = average[smoothedK](dp)
// Normalisation de %K et %D pour les afficher sur le graphique des prix
knormalized = (smoothedK / 100) * (highestHigh - lowestLow) + lowestLow
dnormalized = (d / 100) * (highestHigh - lowestLow) + lowestLow
// Tracer %D sur le graphique des prix
RETURN dnormalized AS "%D (200)" COLOURED(255,165,0)