Indicator · Pine Script v6 · On the chart

Signals MA

by lunarticktrading· code credited to gambcl

The Signals MA indicator calculates a moving average of the close price using either SMA or EMA based on a user-defined length.

View on GitHub

GitHub stars7on the repository
Pine versionv6current
Lines of code55
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update2 weeks ago10 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

55 lines of Pine Script v6 from Signals MA.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Signals MA.txt
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gambcl

//@version=6
indicator("Signals MA", overlay=true)

enum MAType
    SMA = "SMA"
    EMA = "EMA"


////////////////////////////////////////////////////////////////////////////////
// Inputs
////////////////////////////////////////////////////////////////////////////////

int i_length = input.int(20, "Length", minval=1, maxval=999)
MAType i_type = input.enum(MAType.SMA, "Type")
color i_color = input.color(color.white, "Color")

bool i_useSignalColors = input.bool(false, "Use Signal Colors", group="SIGNALS")
color i_buyColor = input.color(color.green, "Buy Color", group="SIGNALS")
color i_sellColor = input.color(color.red, "Sell Color", group="SIGNALS")


////////////////////////////////////////////////////////////////////////////////
// Calculate MA
////////////////////////////////////////////////////////////////////////////////

ma = (i_type == MAType.EMA) ? ta.ema(close, i_length) : ta.sma(close, i_length)

plot(ma, "MA", color=i_color, linewidth=2)

breakout = close[1] <= ma[1] and close > ma
breakdown = close[1] >= ma[1] and close < ma


////////////////////////////////////////////////////////////////////////////////
// Plotting
////////////////////////////////////////////////////////////////////////////////

plotshape(breakout, "Breakout", shape.arrowup, location=location.belowbar, color=i_useSignalColors ? i_buyColor : i_color, display=display.pane)
plotshape(breakdown, "Breakdown", shape.arrowdown, location=location.abovebar, color=i_useSignalColors ? i_sellColor : i_color, display=display.pane)


////////////////////////////////////////////////////////////////////////////////
// Alerts
////////////////////////////////////////////////////////////////////////////////

alertcondition(breakout, "Breakout")
alertcondition(breakdown, "Breakdown")

if (breakout)
    alert("Price closed above " + str.tostring(i_length) + " " + (i_type == MAType.EMA ? "EMA" : "SMA"))
if (breakdown)
    alert("Price closed below " + str.tostring(i_length) + " " + (i_type == MAType.EMA ? "EMA" : "SMA"))

Overview

Signals MA plots this average on the price chart. Breakout signals occur when the close crosses above the moving average from below, and breakdown signals when it crosses below from above. These signals are plotted as arrows on the chart with options to use separate colors for buy and sell signals or the main color. The length, moving average type, and colors are adjustable inputs. The indicator draws all signals directly on the price chart and sends alerts for breakout and breakdown events. It does not include exit rules beyond the signal detections.

Details

Published by

lunarticktrading on GitHub

Code credit

gambcl, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Moving averages, Breakout

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Lengthint20i_length
TypeenumMAType.SMAi_type
Colorcolorcolor.whitei_color
Use Signal Colorsboolfalsei_useSignalColors
Buy Colorcolorcolor.greeni_buyColor
Sell Colorcolorcolor.redi_sellColor
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Acceleration Bands

by capissimo
114 stars

Acceleration Bands is an overlay indicator that plots a volatility envelope around a central simple moving average. It calculates upper and lower boundary bands scaled by the high-to-low bar range relative to the midpoint price, smoothed by an SMA over a user-

Indicator v4 Volatility & bandsMoving averages
Updated 1 year ago · None stated GitHub repository of Acceleration Bands

RSC Trend Trading Study

by readysetcryptocodes
43 stars

This indicator plots Donchian Channels alongside fast and slow simple moving averages directly on the price chart. It generates bullish breakout signals when the high reaches the upper channel while the close is above the 50 SMA (and optionally the 200 SMA). B

Indicator v4 TrendBreakout
Updated 2 years ago · None stated GitHub repository of RSC Trend Trading Study

Candle Stage Analysis

by ChartsLector
41 stars

This indicator classifies market trends into structured stages based on moving average alignments, compression, and ATR distance from the 50-period SMA. It tracks multiple exponential moving averages against the 50 SMA to detect basing phases, breakouts, trend

Indicator v6 TrendMoving averages
Updated 2 days ago · None stated GitHub repository of Candle Stage Analysis

This indicator detects compressed corrective coils inside a higher-timeframe trend and signals when they resolve into clean directional breaks. It plots compression bands, fractal boxes, efficiency scores, and a light dashboard on the price chart. Signals clas

Indicator v6 Volatility & bandsSMC / ICT / price action
Updated yesterday · MIT GitHub repository of Compression Fractal Release [WavesUnchained]

5000x Breakout Scanner

by jmragsdale
8 stars

This indicator marks momentum breakouts on the price chart. A signal appears only when the bar makes a new high over the lookback, volume is at least a chosen multiple of the 20-bar average, the percentage change from the prior close meets a minimum, the close

Indicator v5 BreakoutVolume
Updated 7 weeks ago · None stated GitHub repository of 5000x Breakout Scanner

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers