OPEN-SOURCE SCRIPT
One-Time 50 SMA Trend Start

//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"
)
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"
)
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.