← All scripts
IndicatorOpen sourceVersion 2

MA 20/50

01

Access powerful trading tools designed to identify market trends, detect momentum shifts, and uncover high-quality trading opportunities quickly and effortlessly. Suitable for crypto, stocks, indices, commodities, and forex, each script includes detailed instructions, built-in alerts, and non-repainting logic for a smooth, ready-to-use trading experience.

MA 20/50 — screenshot 1 of 1

Screenshot 1 of 1 · Open image to view full size

About this script

The Linear Regression Trend Navigator is a trend-following indicator that combines statistical regression analysis with adaptive volatility bands to identify and track dominant market trends. It employs linear regression mathematics to establish the underlying trend direction, while dynamically adjusting trend boundaries based on standard deviation calculations to filter market noise and maintain trend continuity. The result is a straightforward visual system where green indicates bullish conditions favoring buy/long positions, and red signals bearish conditions supporting sell/short trades.

Source code

Read and review the complete source before using it in your account.

script("MA 20/50", kind="indicator")

input length = 20
input length2 = 40

ma = ta.sma(close, length)
ma2 = ta.sma(close, length2)

crossUp = ta.crossover(ma, ma2)
crossDown = ta.crossunder(ma, ma2)

plot(ma, title="MA 20", color="#FF0000", width=6)
plot(ma2, title="MA 50", color="#e29625ff", width=2)
plotText(ma, when=crossUp, text="Cross up: {price}", color="#FF0000", position="below")
plotText(ma2, when=crossDown, text="Cross down: {price}", color="#af4c99ff", position="above")

Version history

  1. Version 2

    change 2

    View this version →
  2. Version 1
    View this version →

Discussion · 1

Support this script and join the discussion from your broker’s trading terminal using your author profile.

  1. Andrew Scobelman@andrewscobelmanv2 · Script author ·

    nice script! Thank you