Indicator · Pine Script v5 · On the chart

Mrhyh21 Buy Sell

by g-moe· code credited to goodgains

Mrhyh21 Buy Sell combines Parabolic SAR trend tracking with a 14-period RSI filter to trigger entry signals.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code70
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 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

70 lines of Pine Script v5 from Tradingview/mrhyh21-buy-sell.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

mrhyh21-buy-sell.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("Mrhyh21_buy_sell", overlay = true)

// @keywords: parabolic-sar, rsi-filter, buy-sell-labels, strong-buy, strong-sell, psar-direction, trend-state-fill, overlay-signals, psar-crossover, rsi-threshold, bullish-bearish, state-highlight, alert-conditions, direction-change, momentum-rsi, psar-plot, signal-labels, trade-state, overlay-indicator, rsi-levels

start = 0.02
increment = 0.02
maximum = 0.2
width = 2

bull_css = input.color(color.green, title = 'Bull Color', group = 'Buy/Sell Settings', inline = '0')
bear_css = input.color(color.red, title = 'Bear Color', group = 'Buy/Sell Settings', inline = '0')

showLabels = input(title='Show Buy/Sell Labels ?', defval=true, group = 'Buy/Sell Settings', inline = '1')
highlightState = input(title='Highlight State ?', defval=true, group = 'Buy/Sell Settings', inline = '2')

psar = ta.sar(start, increment, maximum)
dir = psar < close ? 1 : -1

psarColor = dir == 1 ? bull_css : bear_css
psarPlot = plot(highlightState ? psar : na, title='PSAR', style=plot.style_circles, linewidth=width, color=psarColor, display = display.none, editable = false)
plotshape(highlightState and dir == 1 ? psar : na, title = 'PSAR Bull', location = location.absolute, style =shape.triangleup, color = bull_css)
plotshape(highlightState and dir == -1 ? psar : na, title = 'PSAR Bear', location = location.absolute, style =shape.triangledown, color = bear_css)

// rsi
rsi_length = 14
rsi_long = input.int(50, title = 'Buy Above', group = 'Buy/Sell Settings', inline = '3')
rsi_stronglong = input.int(57, title = 'Strong Buy Above', group = 'Buy/Sell Settings', inline = '3')
rsi_short = input.int(50, title = 'Sell Below', group = 'Buy/Sell Settings', inline = '4')
rsi_strongshort = input.int(43, title = 'Strong Sell Below', group = 'Buy/Sell Settings', inline = '4')

if rsi_stronglong < rsi_long
    runtime.error("Strong Buy cannot be less than Buy")
if rsi_strongshort > rsi_short
    runtime.error("Strong Sell cannot be greater than Sell")

rsi_value = ta.rsi(close, rsi_length)

var color longColor = bull_css
var color shortColor = bear_css
var int last_signal = 0

strongbuy = last_signal[1] != 1 and dir == 1 and rsi_value >= rsi_stronglong
buySignal = last_signal[1] != 1 and dir == 1 and rsi_value >= rsi_long

strongsell = last_signal[1] != -1 and dir == -1 and rsi_value <= rsi_strongshort
sellSignal = last_signal[1] != -1 and dir == -1 and rsi_value <= rsi_short

// barcolor(dir == 1 ? color.green : dir == -1 ? color.red : na)
last_signal := barstate.isfirst ? dir : (buySignal or strongbuy) ? 1 : (sellSignal or sellSignal) ? -1 : last_signal[1]

plotshape(buySignal and showLabels ? psar : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(longColor, 0), textcolor=color.new(color.white, 0))
plotshape(strongbuy and showLabels ? psar : na, title='Strong Buy Label', text='Strong Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(longColor, 0), textcolor=color.new(color.white, 0))

plotshape(sellSignal and showLabels ? psar : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(shortColor, 0), textcolor=color.new(color.white, 0))
plotshape(strongsell and showLabels ? psar : na, title='Strong Sell Label', text='Strong Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(shortColor, 0), textcolor=color.new(color.white, 0))

midPricePlot = plot(ohlc4, title='', display=display.none)

fillColor = highlightState ? dir == 1 ? color.new(longColor,90) : color.new(shortColor,90) : color.new(#ffffff,100)
fill(midPricePlot, psarPlot, title='Trade State Filling', color=fillColor)

changeCond = dir != dir[1]
alertcondition(changeCond, title='Alert: PSAR Direction Change', message='PSAR has changed direction!')
alertcondition(buySignal, title='Alert: PSAR/RSI Long', message='PSAR/RSI Long')
alertcondition(sellSignal, title='Alert: PSAR/RSI Short', message='PSAR/RSI Sell')

Overview

Mrhyh21 Buy Sell plots buy, strong buy, sell, and strong sell labels directly on the price chart when the Parabolic SAR direction aligns with specified RSI threshold levels. Users can customize the RSI thresholds for standard and strong signals, toggle visual state highlighting, and adjust display colors.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Oscillators & momentum

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
Bull Colorcolorcolor.greenbull_css
Bear Colorcolorcolor.redbear_css
Show Buy/Sell Labels ?booltrueshowLabels
Highlight State ?booltruehighlightState
Buy Aboveint50rsi_long
Strong Buy Aboveint57rsi_stronglong
Sell Belowint50rsi_short
Strong Sell Belowint43rsi_strongshort
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 RSI Moving Average (ARSIMA) is an overlay indicator that dynamically adjusts its smoothing factor based on the Relative Strength Index (RSI). When the RSI moves toward extreme overbought or oversold conditions, the smoothing factor increases to ma

Indicator v4 Moving averagesOscillators & momentum
Updated 10 days ago · GPL-3.0 GitHub repository of Adaptive RSI Moving Average

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
257 stars

This indicator uses a Lorentzian distance k-nearest neighbors classification algorithm to predict market direction based on up to five technical features, such as RSI, WaveTrend, CCI, and ADX. It compares current feature values against historical bar patterns

Indicator v5 AI / machine learningOscillators & momentum
Updated 6 weeks ago · None stated GitHub repository of Donald - Machine Learning Options
218 stars

TradersPost Trading Checklist is an overlay indicator that evaluates a suite of popular technical conditions for long and short trade setups. It checks session-anchored VWAP, fast and slow EMA alignments and crosses, 200 SMA, RSI overbought or oversold conditi

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of TradersPost Trading Checklist

Daily Trend Filter

by agutinbaigo28
147 stars

Calculates market regime conditions by combining RSI, MACD, and ADX/DMI indicators. It evaluates whether the market is in a strong bullish, strong bearish, neutral, or non-trending regime. The script plots a colored line overlaying the close price to reflect t

Indicator v5 TrendOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of Daily Trend Filter

AAPP

by capissimo
114 stars

This indicator plots an adaptive moving average or scaled RSI divergence line directly on the price chart. It calculates dual RSI series to measure momentum divergence, scales the values to the chart's price range, and constructs an adaptive average filtered b

Indicator v4 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of AAPP

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