indicator · on price · open source

Simple Moving Average

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

Simple Moving Average is the equal-weight baseline. Smooths price by averaging the last N bars of the chosen source — the reference line every other MA is compared against.

  • Raise N for a smoother, laggier line; lower it for faster response.
  • Pair with a faster MA (e.g. EMA 9) to catch crossovers as trend signals.
  • Works on any market; defaults to close and length 20.

Source code

//@version=5
indicator("Simple Moving Average", overlay=true)
len = input.int(20, "Length", minval=1, maxval=500)
src = input.source("close", "Source")
sma = ta.sma(src, len)
p_SMA = plot(sma, "SMA", color=color.blue, linewidth=2)
alertcondition(ta.crossover(close, sma), "Price crosses above SMA", "Price crossed above the SMA")
alertcondition(ta.crossunder(close, sma), "Price crosses below SMA", "Price crossed below the SMA")

Comments

No comments yet.

Sign in to comment.