Indicator · Pine Script v6 · On the chart

MarketMerge v1.5

by mgnyc11

MarketMerge is a price-chart overlay that plots moving averages, a relative strength line, and an S&P 500 comparison.

View on GitHub

GitHub stars6on the repository
Pine versionv6current
Lines of code68
Settings8inputs
LicenceMIT
Last update8 months ago28 Feb 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

68 lines of Pine Script v6 from marketmerge_v1.5.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

marketmerge_v1.5.pine
//@version=6
indicator("MarketMerge v1.5", overlay=true, max_labels_count=100)

// ============================================================================
// MARKETMERGE v1.5 — Chart Overlay Only
// MAs, RS line, S&P overlay, EPS markers — no data panel (see Data Panel)
// ============================================================================

// === INPUTS ===
string grp_rs = "Relative Strength & Benchmark"
string rsBenchmark = input.symbol("SPY", "RS Benchmark", group=grp_rs)
bool showRSline    = input.bool(true, "Show RS Line on Chart", group=grp_rs)
bool showSPYoverlay = input.bool(true, "Show S&P 500 Overlay", group=grp_rs)

string grp_ma = "Moving Averages"
bool showMA21  = input.bool(true, "Show 21 EMA", group=grp_ma)
bool showMA50  = input.bool(true, "Show 50 DMA", group=grp_ma)
bool showMA150 = input.bool(false, "Show 150 DMA", group=grp_ma)
bool showMA200 = input.bool(true, "Show 200 DMA", group=grp_ma)

bool showEPSmarkers = input.bool(true, "Show EPS Markers on Chart")

// === MOVING AVERAGES ===
float ema21 = ta.ema(close, 21)
float ma50  = ta.sma(close, 50)
float ma150 = ta.sma(close, 150)
float ma200 = ta.sma(close, 200)

plot(showMA21  ? ema21 : na, "21 EMA",  color=color.new(#e91e90, 0), linewidth=1)
plot(showMA50  ? ma50  : na, "50 DMA",  color=color.new(#ff0000, 0), linewidth=1)
plot(showMA150 ? ma150 : na, "150 DMA", color=color.new(#f0883e, 0), linewidth=1)
plot(showMA200 ? ma200 : na, "200 DMA", color=color.new(#000000, 0), linewidth=1)

// === BENCHMARK DATA ===
float benchClose = request.security(rsBenchmark, timeframe.period, close)

// === RELATIVE STRENGTH LINE ===
float rsLine = benchClose > 0 ? (close / benchClose) : na
float rsMA = ta.sma(rsLine, 50)
float rsScaled = na(rsLine) ? na : (rsLine / rsMA) * ma200
plot(showRSline ? rsScaled : na, "RS Line", color=color.new(#2196f3, 0), linewidth=1, style=plot.style_line)

// === S&P 500 OVERLAY ===
float spyClose = request.security("SPY", timeframe.period, close)
int refBars = math.min(bar_index, 100)
float stockRef = close[refBars]
float spyRef   = spyClose[refBars]
float spyPctChg = spyRef > 0 ? (spyClose / spyRef) : na
float spyNorm = not na(spyPctChg) and stockRef > 0 ? stockRef * spyPctChg : na
plot(showSPYoverlay ? spyNorm : na, "S&P 500", color=color.new(#888888, 60), linewidth=1, style=plot.style_line)

// === RS LINE NEW HIGH MARKER (current bar only) ===
// Uses 50-bar lookback — catches RS breakouts from recent trend, not all-time
float rsPriorHigh = ta.highest(rsLine[1], 50)
bool rsNewHigh = barstate.islast and not na(rsLine) and not na(rsPriorHigh) and rsLine > rsPriorHigh

if showRSline and rsNewHigh
    label.new(bar_index, rsScaled * 1.01, "RS\nNew High", color=color.new(#2196f3, 0), textcolor=color.white, style=label.style_label_down, size=size.tiny)

// === EPS MARKERS ON CHART ===
string tickerId = syminfo.tickerid
float epsActual = request.earnings(tickerId, earnings.actual, barmerge.gaps_on, barmerge.lookahead_off)

if showEPSmarkers and not na(epsActual)
    string epsLbl = "EPS\n$" + str.tostring(epsActual, "#.##")
    label.new(bar_index, low * 0.98, epsLbl,
         color=color.new(#26a69a, 0), textcolor=color.white,
         style=label.style_label_up, size=size.tiny)

Overview

Users can show a 21-period EMA and 50-, 150-, and 200-period simple averages. The relative strength line divides price by a chosen benchmark, defaulting to SPY, then scales it with a 50-period average and the 200-period average. The SPY overlay is percentage-anchored over up to 100 bars. Actual EPS values are labeled when earnings data are available. On the last bar only, a marker appears if relative strength exceeds its prior 50-bar high. It does not draw a ratings or checklist panel.

Details

Published by

mgnyc11 on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Moving averages, Trend

Markets

Stocks

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
RS BenchmarksymbolSPYrsBenchmark
Show RS Line on ChartbooltrueshowRSline
Show S&P 500 OverlaybooltrueshowSPYoverlay
Show 21 EMAbooltrueshowMA21
Show 50 DMAbooltrueshowMA50
Show 150 DMAboolfalseshowMA150
Show 200 DMAbooltrueshowMA200
Show EPS Markers on ChartbooltrueshowEPSmarkers
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