Indicator · Pine Script v5 · On the chart

Buy/Sell Signals with Support/Resistance (InvestYourAsset)

by theonetrade

Buy/Sell Signals with Support/Resistance by InvestYourAsset is an overlay indicator that combines moving average crossovers, MACD calculations, and pivot-based support and resistance levels.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code50
Settings4inputs
LicenceMIT
Last update2 weeks ago8 Nov 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

50 lines of Pine Script v5 from assets/indicator/bit-exact/buy_sell_signals_with_support_resistance_investyourasset_fa5ADgD2.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

buy_sell_signals_with_support_resistance_investyourasset_fa5ADgD2.pine
//@version=5
indicator("buy/sell signals with Support/Resistance (InvestYourAsset)", overlay=true)

// Input parameters
ma1 = input(12, title="Short MA Period")
ma2 = input(26, title="Long MA Period")

// Fetching data
symbol = input("NA", title="Ticker Symbol")


data = request.security(symbol, "D", close)

// Filter data based on date range
var float filteredClose = na
if (time >= timestamp(year, month, dayofmonth, 00, 00) and time <= timestamp(year, month, dayofmonth, 23, 59))
    filteredClose := close

// MACD Calculation
short_ma = ta.sma(filteredClose, ma1)
long_ma = ta.sma(filteredClose, ma2)
macd_line = short_ma - long_ma

// Signal Generation
positions = ta.crossover(short_ma, long_ma)
signals = positions ? 1 : ta.crossunder(short_ma, long_ma) ? -1 : 0

// Support and Resistance Calculation
lookback = input(20, title="Lookback Period for S&R")
swingHigh = ta.pivothigh(high, lookback, lookback)
swingLow = ta.pivotlow(low, lookback, lookback)

// Plotting
plot(data, color=color.blue, title="Close Price")


plotshape(signals == 1, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Long Signal")
plotshape(signals == -1, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Short Signal")


hline(0, "Zero Line", color=color.gray)
plot(macd_line, color=color.red, title="MACD Oscillator", style=plot.style_histogram, linewidth=1, transp=0)


plot(short_ma, color=color.orange, title="Short MA")
plot(long_ma, color=color.purple, title="Long MA")


plot(swingHigh, color=color.red, style=plot.style_stepline_diamond, linewidth=2, title="Swing High")
plot(swingLow, color=color.green, style=plot.style_stepline_diamond, linewidth=2, title="Swing Low")

Overview

Buy/Sell Signals with Support/Resistance (InvestYourAsset) calculates short and long simple moving averages on filtered close price data, generating buy and sell visual signals when moving averages cross. The indicator also identifies swing highs and lows using a configurable lookback window to plot dynamic support and resistance steplines. Plotted directly on the main price chart, it displays moving averages, signal arrows, pivot levels, and a MACD histogram.

Details

Published by

theonetrade on GitHub

Draws

On the price chart

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.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Short MA Periodint12ma1
Long MA Periodint26ma2
Ticker SymbolstringNAsymbol
Lookback Period for S&Rint20lookback
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

PivotHighLow

by Alorse
368 stars

This indicator calculates pivot high and pivot low points on the price chart based on configurable left and right bar counts. Confirmed pivot highs and lows are plotted with negative bar offsets directly on the price chart using line and cross styles. Addition

Indicator v4 Support & resistanceOscillators & momentum Repaints
Updated 3 months ago · None stated GitHub repository of PivotHighLow
23 stars

This indicator collection calculates and plots previous daily high and low price levels on the chart to identify potential supply and demand zones. It includes real-time intraday high and low calculations, RSI divergence detection across a customizable period

Indicator v4 Support & resistanceDivergence
Updated 3 years ago · None stated GitHub repository of Daily High and Low Strategy

SPY 0DTE Scalper - 1m

by chris-c-thomas
13 stars

This overlay indicator marks CALLS and PUTS labels on the price chart when a strict boolean gate of price structure, momentum, volatility, breadth, and candle confirmation all pass. It plots an EMA ribbon with cloud fill, session-anchored VWAP and standard-dev

Indicator v6 ScalpingMoving averages
Updated 7 months ago · MIT GitHub repository of SPY 0DTE Scalper - 1m

BTE Acc AO SMIO

by f-cksociety
11 stars

This script provides an indicator-based backtesting engine framework that simulates trade entries, exits, and filtering directly on the price chart. It evaluates selected entry rules and multi-layered filters, including moving average trends, volume increases,

Indicator v5 TrendOscillators & momentum
Updated 4 years ago · MPL-2.0 GitHub repository of BTE Acc AO SMIO
5 stars

This indicator combines pivot-based support and resistance levels with multi-timeframe MACD crossovers and a higher-timeframe exponential moving average trend filter. It identifies support and resistance touches using pivot highs and lows within a user-defined

Indicator v4 Oscillators & momentumSupport & resistance Repaints
Updated 3 years ago · Apache-2.0 GitHub repository of MACD + Support / Resistance

More Moving averages scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers