Indicator · Pine Script v5 · On the chart

MA Crossover Table

by suyons· code credited to su02ga

MA Crossover Table is a multi-timeframe indicator that displays trend states in a table overlaid on the price chart.

View on GitHub

GitHub stars7on the repository
Pine versionv5runs as is
Lines of code69
Settings7inputs
LicenceNone statedfile: MPL-2.0
Last update4 months ago21 Jun 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

69 lines of Pine Script v5 from moving-average/06-ma-crossover-table.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

06-ma-crossover-table.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © su02ga

//@version=5
indicator("MA Crossover Table", overlay = true)

time1 = input.timeframe(title="1", defval="1", inline="1", group="Timeframe")
time2 = input.timeframe(title="2", defval="5", inline="1", group="Timeframe")
time3 = input.timeframe(title="3", defval="15", inline="1", group="Timeframe")
time4 = input.timeframe(title="4", defval="60", inline="1", group="Timeframe")

leng1 = input.int(title="1", defval=10, inline = "1", group="MA Length")
leng2 = input.int(title="2", defval=20, inline = "1", group="MA Length")
leng3 = input.int(title="3", defval=60, inline = "1", group="MA Length")

cls1 = request.security(syminfo.tickerid,time1,close)
cls2 = request.security(syminfo.tickerid,time2,close)
cls3 = request.security(syminfo.tickerid,time3,close)
cls4 = request.security(syminfo.tickerid,time4,close)

ma1_1 = ta.sma(cls1,leng1)
ma1_2 = ta.sma(cls1,leng2)
ma1_3 = ta.sma(cls1,leng3)
ma2_1 = ta.sma(cls2,leng1)
ma2_2 = ta.sma(cls2,leng2)
ma2_3 = ta.sma(cls2,leng3)
ma3_1 = ta.sma(cls3,leng1)
ma3_2 = ta.sma(cls3,leng2)
ma3_3 = ta.sma(cls3,leng3)
ma4_1 = ta.sma(cls4,leng1)
ma4_2 = ta.sma(cls4,leng2)
ma4_3 = ta.sma(cls4,leng3)

roc1_1 = ta.roc(ma1_1,4)
roc1_2 = ta.roc(ma1_2,4)
roc1_3 = ta.roc(ma1_3,4)
roc2_1 = ta.roc(ma2_1,4)
roc2_2 = ta.roc(ma2_2,4)
roc2_3 = ta.roc(ma2_3,4)
roc3_1 = ta.roc(ma3_1,4)
roc3_2 = ta.roc(ma3_2,4)
roc3_3 = ta.roc(ma3_3,4)
roc4_1 = ta.roc(ma4_1,4)
roc4_2 = ta.roc(ma4_2,4)
roc4_3 = ta.roc(ma4_3,4)

bull1 = ma1_1 >= ma1_2 and ma1_2 >= ma1_3 and roc1_2 >= 0 and roc1_3 >= 0
bear1 = ma1_1 <= ma1_2 and ma1_2 <= ma1_3 and roc1_2 <= 0 and roc1_3 <= 0
bull2 = ma2_1 >= ma1_2 and ma2_2 >= ma2_3 and roc2_2 >= 0 and roc2_3 >= 0
bear2 = ma2_1 <= ma1_2 and ma2_2 <= ma2_3 and roc2_2 <= 0 and roc2_3 <= 0
bull3 = ma3_1 >= ma3_2 and ma3_2 >= ma3_3 and roc3_2 >= 0 and roc3_3 >= 0
bear3 = ma3_1 <= ma3_2 and ma3_2 <= ma3_3 and roc3_2 <= 0 and roc3_3 <= 0
bull4 = ma4_1 >= ma4_2 and ma4_2 >= ma4_3 and roc4_2 >= 0 and roc4_3 >= 0
bear4 = ma4_1 <= ma4_2 and ma4_2 <= ma4_3 and roc4_2 <= 0 and roc4_3 <= 0

color1 = bull1 ? color.green : bear1 ? color.red : color.black
color2 = bull2 ? color.green : bear2 ? color.red : color.black
color3 = bull3 ? color.green : bear3 ? color.red : color.black
color4 = bull4 ? color.green : bear4 ? color.red : color.black

trend = table.new(position.top_center, 4, 2, color.white, color.black, 1, color.black, 1)
table.cell(trend,0,0,time1,0,0,color.black)
table.cell(trend,1,0,time2,0,0,color.black)
table.cell(trend,2,0,time3,0,0,color.black)
table.cell(trend,3,0,time4,0,0,color.black)
table.cell(trend,0,1,bull1?"BULL":bear1?"BEAR":"NONE",0,0,color1)
table.cell(trend,1,1,bull2?"BULL":bear2?"BEAR":"NONE",0,0,color2)
table.cell(trend,2,1,bull3?"BULL":bear3?"BEAR":"NONE",0,0,color3)
table.cell(trend,3,1,bull4?"BULL":bear4?"BEAR":"NONE",0,0,color4)

Overview

MA Crossover Table computes SMA crossovers for lengths 10, 20 and 60 on timeframes 1, 5, 15 and 60. Bullish conditions trigger when successive SMAs are in uptrend order and rate-of-change is non-negative; bearish conditions trigger on downtrend order with negative rate-of-change. The table reports BULL, BEAR or NONE for each timeframe and MA length combination. Input settings let users change the timeframes and MA periods. The indicator monitors trend consistency across periods but provides no trade entries, exits, stop-loss or position sizing.

Details

Published by

suyons on GitHub

Code credit

su02ga, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Moving averages, Trend

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
1timeframe1time1
2timeframe5time2
3timeframe15time3
4timeframe60time4
1int10leng1
2int20leng2
3int60leng3
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

948 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 10 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter
330 stars

This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab

Indicator v4 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of 3 EMA/SMA + Cross [Alorse]
318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon
257 stars

Donald SPX - Options Trading is an overlay indicator designed for intraday SPX analysis. It plots a 200-period Weighted Moving Average (WMA) on the price chart while evaluating multi-timeframe market structure across Daily, 15-minute, 5-minute, and 2-minute ba

Indicator v5 Moving averagesTrend Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald SPX - Options Trading

60K均線

by TaichiS
219 stars

This multi-timeframe indicator calculates and plots 20-period and 60-period simple moving averages from the 60-minute timeframe directly onto the price chart. The 20-period average displays as a green line, while the 60-period average appears in blue. It serve

Indicator v4 Moving averagesTrend Repaints
Updated 5 years ago · None stated GitHub repository of 60K均線

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