OPEN-SOURCE SCRIPT

One-Time 50 SMA Trend Start

33
//version=5
indicator("One-Time 50 SMA Trend Start", overlay=true)

// ─── Inputs ──────────────────────────────────────────────
smaLength = input.int(50, "SMA Length")

// ─── Calculations ────────────────────────────────────────
sma50 = ta.sma(close, smaLength)
crossUp = ta.crossover(close, sma50)

// Track whether we've already fired today
var bool alerted = false

// Reset alert for new session
if ta.change(time("D"))
alerted := false

// Trigger one signal only
signal = crossUp and not alerted
if signal
alerted := true

// ─── Plots ───────────────────────────────────────────────
plot(sma50, color=color.orange, linewidth=2, title="50 SMA")

plotshape(
signal,
title="First Cross Above",
style=shape.triangleup,
color=color.new(color.green, 0),
size=size.large,
location=location.belowbar,
text="Trend"
)

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.