OPEN-SOURCE SCRIPT

Support et Résistance Automatiques

90
//version=5
indicator("Support et Résistance Automatiques", overlay=true)

// Paramètres de l'utilisateur
lookback = input.int(50, title="Période d'analyse", minval=1)

// Variables pour les niveaux de support et résistance
var float support = na
var float resistance = na

// Trouver le support (plus bas sur la période donnée)
if (low == ta.lowest(low, lookback))
support := low

// Trouver la résistance (plus haut sur la période donnée)
if (high == ta.highest(high, lookback))
resistance := high

// Tracer les niveaux de support et de résistance
if (not na(support))
line.new(bar_index, support, bar_index + 1, support, color=color.green, width=2, extend=extend.right)

if (not na(resistance))
line.new(bar_index, resistance, bar_index + 1, resistance, color=color.red, width=2, extend=extend.right)

// Affichage des niveaux actuels sur le graphique
if (not na(support))
label.new(bar_index, support, text="Support: " + str.tostring(support), color=color.new(color.green, 80), textcolor=color.white, size=size.small)

if (not na(resistance))
label.new(bar_index, resistance, text="Résistance: " + str.tostring(resistance), color=color.new(color.red, 80), textcolor=color.white, size=size.small)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.