//@version=6 indicator("True Day Open (RTH) - 09:30 ET", overlay=true)
// === Inputs === sess = input.session("0930-1600", "Session RTH (heure locale du fuseau ci-dessous)") tz = input.string("America/New_York", "Fuseau horaire", options=["America/New_York","America/Chicago","UTC"]) showLabel = input.bool(true, "Afficher l’étiquette") extendLine = input.bool(true, "Étendre la ligne jusqu’à la fin de la journée") lineCol = input.color(color.new(color.blue, 0), "Couleur de la ligne") lblCol = input.color(color.new(color.blue, 0), "Couleur de l’étiquette")
// === Détection du début de session RTH === inSess = not na(time(timeframe.period, sess, tz)) startSess = inSess and not inSess[1]
// === Calcul du True Day Open === var float tdo = na tdo := startSess ? open : tdo[1]
// === Objets par journée === var line tdoLine = na var label tdoLbl = na
if startSess // Supprimer les anciens objets if not na(tdoLine) line.delete(tdoLine) if not na(tdoLbl) label.delete(tdoLbl)
// Créer la ligne à partir du bar d’ouverture RTH tdoLine := line.new( x1 = bar_index, y1 = tdo, x2 = bar_index + 1, y2 = tdo, xloc = xloc.bar_index, extend = extendLine ? extend.right : extend.none, color = lineCol, width = 2 )
// Créer l’étiquette if showLabel tdoLbl := label.new( x = bar_index, y = tdo, text = "TDO " + str.tostring(tdo, format.mintick), xloc = xloc.bar_index, yloc = yloc.price, style = label.style_label_left, textcolor = color.white, color = lblCol, size = size.normal )
// === Mise à jour dynamique === if not na(tdoLine) line.set_x2(tdoLine, bar_index) line.set_extend(tdoLine, extendLine ? extend.right : extend.none)
if showLabel and not na(tdoLbl) label.set_x(tdoLbl, bar_index)
// === Alertes === bullBreak = ta.crossover(close, tdo) bearBreak = ta.crossunder(close, tdo) alertcondition(bullBreak, title="Cassure haussière du TDO", message="Cassure haussière du True Day Open") alertcondition(bearBreak, title="Cassure baissière du TDO", message="Cassure baissière du True Day Open")
// === Trace caché pour Data Window === plot(tdo, title="True Day Open (valeur)", display=display.none)
//@version=6
indicator("True Day Open (RTH) - 09:30 ET", overlay=true)
// === Inputs ===
sess = input.session("0930-1600", "Session RTH (heure locale du fuseau ci-dessous)")
tz = input.string("America/New_York", "Fuseau horaire", options=["America/New_York","America/Chicago","UTC"])
showLabel = input.bool(true, "Afficher l’étiquette")
extendLine = input.bool(true, "Étendre la ligne jusqu’à la fin de la journée")
lineCol = input.color(color.new(color.blue, 0), "Couleur de la ligne")
lblCol = input.color(color.new(color.blue, 0), "Couleur de l’étiquette")
// === Détection du début de session RTH ===
inSess = not na(time(timeframe.period, sess, tz))
startSess = inSess and not inSess[1]
// === Calcul du True Day Open ===
var float tdo = na
tdo := startSess ? open : tdo[1]
// === Objets par journée ===
var line tdoLine = na
var label tdoLbl = na
if startSess
// Supprimer les anciens objets
if not na(tdoLine)
line.delete(tdoLine)
if not na(tdoLbl)
label.delete(tdoLbl)
// Créer la ligne à partir du bar d’ouverture RTH
tdoLine := line.new(
x1 = bar_index, y1 = tdo,
x2 = bar_index + 1, y2 = tdo,
xloc = xloc.bar_index,
extend = extendLine ? extend.right : extend.none,
color = lineCol, width = 2
)
// Créer l’étiquette
if showLabel
tdoLbl := label.new(
x = bar_index, y = tdo,
text = "TDO " + str.tostring(tdo, format.mintick),
xloc = xloc.bar_index,
yloc = yloc.price,
style = label.style_label_left,
textcolor = color.white,
color = lblCol,
size = size.normal
)
// === Mise à jour dynamique ===
if not na(tdoLine)
line.set_x2(tdoLine, bar_index)
line.set_extend(tdoLine, extendLine ? extend.right : extend.none)
if showLabel and not na(tdoLbl)
label.set_x(tdoLbl, bar_index)
// === Alertes ===
bullBreak = ta.crossover(close, tdo)
bearBreak = ta.crossunder(close, tdo)
alertcondition(bullBreak, title="Cassure haussière du TDO", message="Cassure haussière du True Day Open")
alertcondition(bearBreak, title="Cassure baissière du TDO", message="Cassure baissière du True Day Open")
// === Trace caché pour Data Window ===
plot(tdo, title="True Day Open (valeur)", display=display.none)