Indicator · Pine Script v5 · On the chart

Major Buy Setup

by dcaoyuan

Major Buy Setup plots a 20-period and a 50-period simple moving average on the price chart.

View on GitHub

Repaints

GitHub stars55on the repository
Pine versionv5runs as is
Lines of code13
Settings0inputs
LicenceApache-2.0
Last update6 months ago20 Apr 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

13 lines of Pine Script v5 from public/indicators/majorbuy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

majorbuy.pine
//@version=5
indicator("Major Buy Setup", overlay=true)
sma20 = ta.sma(close, 20)
sma50 = ta.sma(close, 50)
plot(sma20, color=color.blue, title="SMA 20")
plot(sma50, color=color.orange, title="SMA 50")

bull_engulfing = close > open and close[1] < open[1] and close >= open[1] and open <= close[1]
upper_shadow = high - close
range_ = high - low
bald_bull = close > open and upper_shadow <= range_ * 0.05
major_buy = bull_engulfing and bald_bull
plotshape(major_buy, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.large, text="BUY")

Overview

Major Buy Setup marks a buy when the current bar is both a bullish engulfing candle and a bald bull candle, defined as a green candle whose upper shadow is no more than five percent of the bar range. A large green triangle labeled BUY appears below that bar. There are no user inputs. The marker uses the live bar's close, high, and low, so it can change until that bar closes. It does not manage exits or position size.

Details

Published by

dcaoyuan on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Moving averages, Candlestick patterns

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Topics

aicharttradingvibepinescripttechnical-analysispinestock

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

285 stars

Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

Smoothed candles

by be-thomas
65 stars

This indicator draws smoothed candlesticks on the price chart. It applies a simple moving average of a user-set length, defaulting to nine, separately to open, high, low, and close, then plots those four values with plotcandle. Wick color is green when the raw

Indicator v5 Moving averagesCandlestick patterns
Updated 4 days ago · GPL-3.0 GitHub repository of Smoothed candles

30 min Pivot

by ChartsLector
41 stars

30 min Pivot is an overlay indicator that plots an exponential moving average (EMA) calculated from a specified timeframe (default 30 minutes) and flags specific multi-bar candle setups. It checks the relative distance between price and the higher-timeframe EM

Indicator v5 Moving averagesCandlestick patterns
Updated 2 days ago · None stated GitHub repository of 30 min Pivot

Hanging Man - Bearish

by TWODS-CAPITAL
37 stars

This overlay indicator marks a bearish hanging man candlestick on the price chart. It looks for a small real body sitting in the upper part of the range, a lower shadow at least twice the body, and no upper shadow, and only while an uptrend filter is active. T

Indicator v5 Candlestick patternsTrend
Updated 3 years ago · MIT GitHub repository of Hanging Man - Bearish

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