Indicator · Pine Script v5 · On the chart

Combined 3EMA and UT Bot Alerts with 5 EMA Trend Alert

by mayur-ml

This indicator plots four exponential moving averages (50, 100, 200, and 5 periods) on the price chart.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code70
Settings7inputs
LicenceMIT
Last update2 years ago31 May 2024

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 3 and 5 EMA__UTBot_S-WA.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

3 and 5 EMA__UTBot_S-WA.pine
//@version=5
indicator("Combined 3EMA and UT Bot Alerts with 5 EMA  Trend alart", shorttitle="3/5EMA_UTBot_TS-WA", overlay=true)

// Inputs for EMAs
EMA1 = input.int(50, minval=1, title="EMA1")
EMA2 = input.int(100, minval=1, title="EMA2")
EMA3 = input.int(200, minval=1, title="EMA3")
EMA4 = input.int(5, minval=1, title="EMA4")

// Plot EMAs
plot(ta.ema(close, EMA1), color=color.red, linewidth=2)
plot(ta.ema(close, EMA2), color=color.yellow, linewidth=2)
plot(ta.ema(close, EMA3), color=color.purple, linewidth=2)
plot(ta.ema(close, EMA4), color=color.blue, linewidth=2)

// Inputs for UT Bot Alerts
a = input.int(1, title="Key Value (sensitivity)")
c = input.int(10, title="ATR Period")
h = input.bool(false, title="Signals from Heikin Ashi Candles")

xATR = ta.atr(c)
nLoss = a * xATR

src = h ? request.security(syminfo.tickerid, timeframe.period, close, lookahead=barmerge.lookahead_off) : close

var float xATRTrailingStop = na
if na(xATRTrailingStop[1])
    xATRTrailingStop := src
else
    if src > xATRTrailingStop[1] and src[1] > xATRTrailingStop[1]
        xATRTrailingStop := math.max(xATRTrailingStop[1], src - nLoss)
    else if src < xATRTrailingStop[1] and src[1] < xATRTrailingStop[1]
        xATRTrailingStop := math.min(xATRTrailingStop[1], src + nLoss)
    else
        xATRTrailingStop := src > xATRTrailingStop[1] ? src - nLoss : src + nLoss

var int pos = na
if na(pos[1])
    pos := na
else
    if src[1] < xATRTrailingStop[1] and src > xATRTrailingStop[1]
        pos := 1
    else if src[1] > xATRTrailingStop[1] and src < xATRTrailingStop[1]
        pos := -1
    else
        pos := pos[1]

xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue

ema_1 = ta.ema(src, 1)
above = ta.crossover(ema_1, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema_1)

buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below

barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop

plotshape(buy, title="Buy", text='Buy', style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.tiny)
plotshape(sell, title="Sell", text='Sell', style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.tiny)

barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)

alertcondition(buy, title="UT Long", message="UT Long")
alertcondition(sell, title="UT Short", message="UT Short")

// Additional alert for "red signal"
alertcondition(barsell, title="Red Signal Alert", message="Red Signal: Consider Selling")

Overview

Combined 3EMA and UT Bot Alerts with 5 EMA Trend Alert computes an ATR-based trailing stop using sensitivity and period settings. The trailing stop updates based on price action and Heikin Ashi candles if enabled. Signals trigger on crossovers between a 1-period EMA and the trailing stop, producing buy and sell labels, bar color changes, and alerts. Main settings adjust EMA lengths, ATR period, and Heikin Ashi usage. It draws solely on the price chart with no separate pane.

Details

Published by

mayur-ml on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, Volatility & bands

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
EMA1int50EMA1
EMA2int100EMA2
EMA3int200EMA3
EMA4int5EMA4
Key Value (sensitivity)int1a
ATR Periodint10c
Signals from Heikin Ashi Candlesboolfalseh
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

318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

Bollinger Bands Force

by harryguiacorn
219 stars

This indicator modifies standard Bollinger Bands to measure directional trend force based on line alignment. It calculates a simple moving average basis along with upper and lower volatility bands. When all three lines move upward or downward simultaneously, i

Indicator v5 Volatility & bandsTrend
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Force

Adaptive MA Slope

by capissimo
114 stars

This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison

Indicator v4 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of Adaptive MA Slope

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