Indicator · Pine Script v5 · On the chart

SuperTrend + MACD + EMA

by redm3· code credited to macmwz20

This overlay indicator plots a SuperTrend using a 10-period ATR with a multiplier of 3, drawing up and down stop lines and a faint trend fill on the price chart.

View on GitHub

GitHub stars46on the repository
Pine versionv5runs as is
Lines of code75
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update3 years ago21 May 2023

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

75 lines of Pine Script v5 from pinescript.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

pinescript.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © macmwz20


//@version=5
indicator('SuperTrend + MACD + EMA', overlay=true)

src = close
fast_ema = ta.ema(src, 9)
slow_ema = ta.ema(src, 18)

fast_macd = ta.ema(src, 12)
slow_macd = ta.ema(src, 26)
macd = fast_macd - slow_macd
signal = ta.ema(macd, 9)
hist = macd - signal

// Volume Filter
volume_ma = ta.sma(volume, 20)
volume_increase = volume > volume_ma

// Deternine if we are currently LONG
isLong = false
isLong := nz(isLong[1], false)

// Determine if we are currently SHORT
isShort = false
isShort := nz(isShort[1], false)

// Buy only if the buy signal is triggered, we are not already long, and volume is high
LONG = not isLong and fast_ema > slow_ema and macd > signal and volume_increase

// Sell only if the sell signal is triggered, we are not already short, and volume is high
SHORT = not isShort and fast_ema < slow_ema and macd < signal and volume_increase

if LONG
    isLong := true
    isShort := false
    isShort

if SHORT
    isLong := false
    isShort := true
    isShort

// Supertrend Calculation
atr = 3 * ta.atr(10)
longStop = hl2 - atr
longStopPrev = nz(longStop[1], longStop)
longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = hl2 + atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and close > shortStopPrev ? 1 : dir == 1 and close < longStopPrev ? -1 : dir


// Line Plots
bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(dir == 1 ? longStop : na, title='Up Trend Line', style=plot.style_linebr, linewidth=1, color=color.new(color.green, 0))
downTrend = plot(dir != 1 ? shortStop : na, title='Down Trend Line', style=plot.style_linebr, linewidth=1, color=color.new(color.red, 0))

//Fill Background
fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false, title='Uptrend Background')
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false, title='Downtrend Background')

//Bar Colour
barcolor(dir == 1 and isLong ? color.green : dir != 1 and isShort ? color.red : color.blue)

// Buy/Sell Label Plots
confirmLONG = fast_ema > slow_ema and macd > signal and longStop
confirmSHORT = fast_ema > slow_ema and macd > signal and longStop
plotshape(not confirmLONG[1] and confirmLONG, title='Buy Label', style=shape.labelup, location=location.belowbar, size=size.normal, text='Buy', textcolor=color.new(color.white, 0), color=color.new(color.green, 0))
plotshape(not confirmSHORT[1] and confirmSHORT, title='Sell Label', style=shape.labeldown, location=location.abovebar, size=size.normal, text='Sell', textcolor=color.new(color.white, 0), color=color.new(color.red, 0))

Overview

SuperTrend + MACD + EMA compares a 9-period EMA with an 18-period EMA and a 12/26/9 MACD against its signal, and it requires volume above a 20-period average before setting a long or short state. Bar color reflects SuperTrend direction together with that state. Buy and sell labels share the same confirmation condition, and there are no exits, stops, or user inputs.

Details

Published by

redm3 on GitHub

Code credit

macmwz20, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Oscillators & momentum, Moving averages, Volume

Markets

Crypto

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.

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

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

Bte Acc

by f-cksociety
11 stars

Bte Acc is a chart indicator form of the PineCoders Backtesting and Trading Engine. It seeks an entry trigger from a main or alternate entry method, then checks trade direction, filters, date range, ATR readiness, and remaining capital before filling on the ne

Indicator v5 TrendOscillators & momentum Repaints
Updated 4 years ago · MPL-2.0 GitHub repository of Bte Acc

This indicator overlays a Hull Moving Average and three Exponential Moving Averages on the price chart while monitoring signals from MACD, Stochastic Oscillator, and Time Segmented Volume. It tracks trend direction changes, MACD histogram color shifts from bri

Indicator v5 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of MACD Signals with Alert System
2 stars

MasterTrader V1 is an indicator that plots two exponential moving averages (fast length 9, slow length 21) and RSI (length 14) on the close price chart. It generates long entry signals when the fast EMA crosses above the slow EMA, RSI stays between 30 and 70,

Indicator v6 TrendOscillators & momentum
1 stars

This indicator calculates dual Exponential Moving Averages alongside their slopes, normalized distance, and momentum to detect trend shifts on the price chart. It plots standard EMA crossovers while also assessing early warning conditions when EMAs approach ea

Indicator v6 TrendMoving averages
Updated 5 days ago · None stated GitHub repository of Gelişmiş EMA Trend Analizi
1 stars

This Pine Script indicator plots fast and slow EMA lines on the price chart to identify trend direction. It applies RSI and MACD filters to confirm momentum strength and checks volume against its average for confirmation. Buy signals trigger on fast EMA crossi

Indicator v6 TrendOscillators & momentum
Updated 2 months ago · Custom licence GitHub repository of Lesson 5 Buy Sell Logic Demo

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