Indicator · Pine Script v5 · On the chart

Parabolic SAR + EMA 200 + MACD Signals

by saleh-ato· code credited to Saleh_Toodarvari

This indicator plots Parabolic SAR circles and a configurable exponential moving average on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code70
Settings18inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago16 Jun 2025

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 Parabolic SAR + EMA 200 + MACD Signals/SAR-EMA200-MACD.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

SAR-EMA200-MACD.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Saleh_Toodarvari

//@version=5
indicator(title="Parabolic SAR + EMA 200 + MACD Signals", shorttitle="SAR EMA MACD", overlay=true, timeframe="", timeframe_gaps=true)
// Inputs
sar_start = input(0.02)
sar_increment = input(0.02)
sar_maximum = input(0.2, "Max Value")
ema_len = input.int(200, minval=1, title="Length")
ema_src = input(close, title="Source")
ema_offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
macd_fast_length = input(title="Fast Length", defval=12)
macd_slow_length = input(title="Slow Length", defval=26)
macd_src = input(title="Source", defval=close)
signal_length = input.int(title="Signal Smoothing",  minval = 1, maxval = 50, defval = 9)
sma_source = input.string(title="Oscillator MA Type",  defval="EMA", options=["SMA", "EMA"])
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])
// Colors
col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD")
col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal")
col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
// Parabolic SAR
SAR = ta.sar(sar_start, sar_increment, sar_maximum)
plot(SAR, "ParabolicSAR", style=plot.style_circles, color=#2962FF)
// EMA 200
EMA_200 = ta.ema(ema_src, ema_len)
plot(EMA_200, title="EMA", color=color.blue, offset=ema_offset)
// MACD
fast_ma = sma_source == "SMA" ? ta.sma(macd_src, macd_fast_length) : ta.ema(macd_src, macd_fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(macd_src, macd_slow_length) : ta.ema(macd_src, macd_slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
delta = macd - signal
// Conditions
main_trend=if ohlc4<EMA_200
    "Bearish"
else
    "Bullish"

sar_long = if SAR<low
    true
else
    false
sar_short = if SAR>high
    true
else
    false

macd_long = if (ta.crossover(delta, 0))
    true
else
    false
macd_short = if (ta.crossunder(delta, 0))
    true
else
    false
// Long
buy_signal= sar_long and macd_long and (main_trend=="Bullish")
// Short
sell_signal= sar_short and macd_short and (main_trend=="Bearish")
// Plots
plotshape(buy_signal, title="Buy Label", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(sell_signal, title="Sell Label", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
//_________________alerts_________________
alertcondition(buy_signal, title='SAR EMA200 MACD Buy signal!', message='Buy signal')
alertcondition(sell_signal, title='SAR EMA200 MACD Sell signal!', message='Sell signal')

Overview

Parabolic SAR + EMA 200 + MACD Signals treats the average of open, high, low, and close above the EMA as bullish and below it as bearish. A buy label appears when SAR is below the low, the MACD histogram crosses above zero, and the trend is bullish. A sell label uses the opposite SAR and MACD conditions in a bearish trend. Inputs change SAR step values, EMA length, source and offset, and MACD lengths and moving-average types. It is an indicator with alerts and no exit or stop rules.

Details

Published by

saleh-ato on GitHub

Code credit

Saleh_Toodarvari, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Oscillators & momentum, Moving averages

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

pinescriptindicatorpinescript-indicators

Settings

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

SettingTypeDefaultVariable
sar_startfloat0.02sar_start
sar_incrementfloat0.02sar_increment
Max Valuefloat0.2sar_maximum
Lengthint200ema_len
Sourcesourcecloseema_src
Offsetint0ema_offset
Fast Lengthint12macd_fast_length
Slow Lengthint26macd_slow_length
Sourcesourceclosemacd_src
Signal Smoothingint9signal_length
Oscillator MA TypestringEMAsma_source
Signal Line MA TypestringEMAsma_signal
Show all 18 settings
SettingTypeDefaultVariable
MACD Line  color#2962FFcol_macd
Signal Line  color#FF6D00col_signal
Above   Growcolor#26A69Acol_grow_above
Fallcolor#B2DFDBcol_fall_above
Below Growcolor#FFCDD2col_grow_below
Fallcolor#FF5252col_fall_below
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
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

Signal Strategy 15m

by tripolskypetr
72 stars

This indicator generates trend-following trade signals on the price chart by combining moving average crossovers with multi-factor filters. It triggers entry alerts when fast and slow EMAs cross in the direction of a baseline trend EMA, confirmed by non-extrem

Indicator v5 TrendMoving averages
Updated 3 days ago · MIT GitHub repository of Signal Strategy 15m
56 stars

Double Screened Decision is a multi-timeframe trend and momentum indicator overlaid directly on the price chart. It dynamically selects a higher timeframe based on the active chart resolution to evaluate higher-timeframe MACD, Bollinger Bands, RSI, and Stochas

Indicator v5 TrendMoving averages Repaints
Updated 4 months ago · None stated GitHub repository of Double Screened Decision

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